Home Forums C Programming Beginner’s help Reply To: Beginner’s help

#3370
Humayan
Participant

For the first part you could do:
 

#include
#include
int main(void)
{
 // open a text file for reading
 FILE * in_file;
 in_file = fopen("c:\programs\help\text1.txt","r");
 // open a text file for writing
 FILE * out_file ;
 out_file = fopen("c:\programs\help\text2.txt","w");

 if ( ! in_file || ! out_file )
 {
  printf ( "a file did not openn" );
  return 1;
 }
 char ch = fgetc ( in_file );
 while ( ch != EOF )
 {
  //write to file
  fputc ( ch , out_file );
  ch = fgetc ( in_file );
 }
 fclose(in_file);
 fclose(out_file);
// system("pause");
 return 0;
}