C Program to open and write to a text file using fprintf.

 

C Program to open and write to a text file using fprintf.

#include <stdio.h>

#include <conio.h> 

#include <stdlib.h>

 void  main()

{

   int number;

   FILE *fileptr;

fileptr = fopen("D:\\program.txt","w");

   if( fileptr == NULL)

   {

      printf("Error in file !");  

      exit(1);            

   }

printf("Enter number: ");

scanf("%d",&number);

fprintf( "fileptr %d",number);

   fclose( fileptr );

    getch();

   }

 

Comments

Popular posts from this blog

C Program to print swap number using third variables