0

help me with this....here i m trying to write into a file(which i have already created n saved in C:\ drive) from stdinput i.e. keyboard and then reading from that file and displaying on stdoutput....but its isn't working... :rolleyes: :rolleyes:
tell me why?????????

by the way i m using GCC as compiler.......

#include <stdio.h>
#include <stdlib.h>


int main()
{
   
FILE *fp ;
int offset ;
char ch ;
 if ( ( fp = fopen ( "C:\q.txt", "w" )) == NULL ) 
{ 
printf ( "\nUnable to open file" ) ;
exit(0) ; 
}


while((ch=getchar())!=EOF)
putc(ch,fp);

fclose ( fp ) ;

printf("\nData output\n\n");

 if ( ( fp = fopen ( "C:\q.txt", "r" )) == NULL )
{ 
printf ( "\nUnable to open file" ) ;
exit(0) ; 
}


while((ch=getc(fp))!=EOF)
printf ( "%c", ch ) ; 

fclose ( fp ) ; 


  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 WolfPack
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.