*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 >>

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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.