C File Operations

////////   file_operations.c  ////////
 #include <stdio.h>
 int main(void)
 {
 char temp[100];
 FILE *write_to_file = fopen("file.txt","w");
 fprintf(write_to_file,"%08x",0xC12E3A4);
 fclose(write_to_file);
 FILE *read_from_file = fopen("file.txt", "rb");
 fscanf(read_from_file,"%s",temp);
 printf("String read from file=%sn",temp);
 fclose(read_from_file);
 return 0;
 }

[raja@AGRAJA ~]$ gcc -Wall file_operations.c
[raja@AGRAJA ~]$ ./a.out

String read from file=0c12e3a4

Download here:

c_file_operations.doc

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s