Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * If you have nerdy friends who like to talk in binary encoded ASCII
- * and if you are not a digital machine
- * or you can't read the ascii values and figure out whats written
- * all you need to do is save the strings of 1s and 0s in fin.txt file
- * in default directory and run this code. :)
- *
- */
- #include<stdio.h>
- int main()
- {
- int i,j,k;
- char c, d;
- FILE *in;
- in = fopen("fin.txt","r");
- if (in==NULL) {
- printf("bye");
- return 1;
- } else {
- printf("ok");
- }
- while( 1) {
- j=d=0;
- do{
- c= fgetc(in);
- if(c=='1'){
- d<<=1;
- d = d|1;
- j++;
- } else if(c=='0') {
- d<<=1;
- j++;
- } else if (c==EOF) {
- return 0;
- } else {
- printf("%c",c);
- }
- }while(j<8);
- printf("%c", d);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement