C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

Write a C program to open a file in read/write mode. Read and Write new information in the file?

0 votes
39 views
asked Jan 7, 2014 by smith Geek (15,340 points)

1 Answer

0 votes

#include<stdio.h>

#include<conio.h>

#include<process.h>

void main()

{

FILE *fp;

char c=‟ „;

clrscr();

fp=fopen(“data.txt”, “r+”);

if(fp= = NULL)

{

Printf(“cannot open file”);

exit(1);

}

Printf(“\n Contents read:”);

While(!feof(fp))

Printf(“%c” getc(fp));

Printf(“write data & to stop press „.‟ :”);

while(c=‟!‟)

{

C=getche();

fputc(c,fp);

}

getch();

}

Output:

Contents read: Help me.

Write data & to stop press‟.‟: I am in trouble. 

answered Jan 7, 2014 by rajesh Guru (39,140 points)

...