Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS 1
- #include <stdio.h>
- #include <string.h>
- #include<math.h>
- int main() {
- FILE *f = fopen("F:\\tmp\\iagova.txt", "r");
- fseek(f, 0, SEEK_END);
- int pos = ftell(f);
- fseek(f, 0, SEEK_SET);
- char *data = malloc(pos);
- fread(data, pos, 1, f);
- fclose(f);
- data[pos] = '\0';
- printf("%s\n\n", data);
- int i = 0;
- int s = 0;
- int k = 0;
- pos--;
- while (pos >= 0)
- {
- s += (data[pos] - '0')*pow(2, k);
- pos--;
- k++;
- }
- printf("%d ", s);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement