Created
April 1, 2013 23:55
-
-
Save anonymous/5288805 to your computer and use it in GitHub Desktop.
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
void write() //Pretty much whole function is self explanatory | |
{ | |
char str[1000]; | |
FILE* f = fopen("input.bin", "wb"); | |
if(f == NULL) | |
{ | |
perror("File opening error\n"); | |
exit(1); | |
} | |
fseek(f, 0, SEEK_SET); | |
int i; | |
for (i = 0; i < size; i++) | |
{ | |
fprintf(f, "%s;%s;%s;%s", foo[i].kid, foo[i].jid, foo[i].name, foo[i].time); | |
} | |
fclose(f); | |
} | |
void read(char* filename) | |
{ | |
fp = fopen(filename, "rb"); | |
int i = 0; | |
while (!feof(fp)) | |
{ | |
if (fp==NULL) | |
{ | |
perror("File opening error\n"); | |
exit(1); | |
} | |
fscanf(fp,"%[^;]; %[^;]; %20[^\;]; %18[^\;]", foo[i].kid, foo[i].jid,foo[i].name, foo[i].time); //Little edit when taking the "time string" not to cut-off after first ' ' | |
i++; | |
} | |
size = i; | |
fclose(fp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment