Google

Friday, January 22, 2010

CSC202 & ENG4033M : File Processing

//File Processing
#include "stdio.h"
void main()
{
char s[] = "avatar";

FILE *f;
f = fopen("D:\\data.txt","w");//w for overwrite
if(!f) return;
fprintf(f,"%s",s);
fclose(f);

f = fopen("D:\\data.txt","r");
if(!f) return;
char t[64];
fscanf(f,"%s",t);
fclose(f);

printf("Read: %s",t);
}