/*ogrenci.txt dosyasina klavyeden girilen ad ve notlari yazdirir*/

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


int main()
{ 
    
   char name[ 30 ]; 
   int grade;  
   
   FILE *cfPtr;    

   
   if ( ( cfPtr = fopen( "students.txt", "w" ) ) == NULL ) {
      printf( "File could not be opened\n" );
   } 
   
   
   else { 
      
      fprintf(stdout, "Enter the name and the grade of the first student\n");
      fscanf(stdin, "%s %d", name, &grade);

      int c = 2;
      
      while ( !feof( stdin ) ) {
          
             
         fprintf( cfPtr, "%s %d\n", name, grade );
         
         fprintf(stdout, "Enter the name and the grade of the %dth student\n", c++);
         
         fscanf(stdin, "%s %d", name, &grade);
         
              
      } 
      
      fclose( cfPtr ); 
   } 
   
printf("\n\n");
system("pause");

return 0; 

}




 

