0

*make sure that this program give correct o/p to corresponding i/p/*

#include<stdio.h>

#include<conio.h>

void main()

{

 char fname[15];

 FILE *f;

 char c;

 printf("Enter the file name");

 scanf("%s",&fname);

 f=fopen(fname,"w");

 while(c=getch()!='#')

          fputc(f,c);

 

 fclose(f);

 f=fopen(fname,"r");

 while(c=fgetc(f)!=EOF)

  printf("%c",c);

  getch();

  fclose(f);

  f=fopen(fname,"r");

 while(f=fgetc(c)!=EOF)

  printf("%c",c);

  getch();

 

 

 }

<< moderator edit: added [co[u][/u]de][/co[u][/u]de] tags >>

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Dave Sinkula
0

This:

while(f=fgetc(c)!=EOF)

is equivalent to this:

while(f=(fgetc(c)!=EOF))

But what you want is this:

while((f=fgetc(c))!=EOF)

And you likely meant for f to be c . And c should be an int . And main returns an int .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.