#include <string.h> |
#include <stdio.h> |
#include <conio.h> |
int main ( void ) |
{ |
FILE *stream; |
char string[] = "This is a test" ; |
char ch; |
/* open a file for update */ |
stream = fopen ( "DUMMY.FIL" , "w+" ); |
/* write a string into the file */ |
fwrite ( string, strlen ( string ), 1, stream ); |
/* seek to the beginning of the file */ |
fseek ( stream, 0, SEEK_SET ); |
do |
{ |
/* read a char from the file */ |
ch = fgetc ( stream ); |
/* display the character */ |
putch ( ch ); |
} |
while ( ch != EOF ); |
fclose ( stream ); |
return 0; |
} |