GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Monday, March 21, 2011

C - File I/O

The functions used:
For writing to a file
1. fprintf( file_pointer, string_format, argument_lists )
2. fputs( string_data, file_pointer )
3. fwrite
4. fputc( char, file_pointer )
5. putc( char, file_pointer )

For reading from a file, use:
1. fscanf ( file_pointer, string_format, argument_lists )
2. fread
3. fgetc( file_pointer ) : char
4. fgets( char_array, size, file_pointer )


FILE *input;
input = fopen("lola.txt","r");

char a;
while(a != EOF){
    a = fgetc(input);
    putchar(a);
}
fclose(input);
Share/Bookmark

No comments:

Post a Comment