Last active
August 29, 2015 14:04
-
-
Save pol51/3bb2044591b99c4fe225 to your computer and use it in GitHub Desktop.
read inverted word from a text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(int argc, char **argv) | |
{ | |
FILE *file = fopen("data.txt", "r"); | |
if (!file) | |
return EXIT_FAILURE; | |
char buffer[256]; | |
while (fgets(buffer, sizeof(buffer), file)) | |
{ | |
int i, value = 0; | |
for (i = 8; --i >= 0;) | |
value = (value<<1) | buffer[i] == '1'; | |
printf("%d\n", value); | |
} | |
fclose(file); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment