search
Login

Categories


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

3.8k questions

4k answers

117 comments

10.7k users

0 votes
129 views
asked Geek 15.3k points 16 41 63

1 Answer

0 votes

#include<stdio.h>

#include<conio.h>

#include<process.h>

void main()

{

FILE *fp;

char c=‟ „;

clrscr();

fp=fopen(“data.dat”, “wb”);

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);

}

fclose(fp);

fp=fopen(“data.dat”, “rb”);

printf(“\n contents read:”);

while(!feof(fp))

printf(“%c”, getc(fp));

getch();

}

Output:

Contents read: Help me.

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

answered Guru 39.1k points 10 21 33

Related questions

0 votes
1 answer 128 views
0 votes
1 answer 73 views
0 votes
1 answer 46 views
...