Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

fopen examples in c

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

int main()
{
   int num;
   FILE *fptr;

   // use appropriate location if you are using MacOS or Linux
   fptr = fopen("C:program.txt","w");

   if(fptr == NULL)
   {
      printf("Error!");   
      exit(1);             
   }

   printf("Enter num: ");
   scanf("%d",&num);

   fprintf(fptr,"%d",num);
   fclose(fptr);

   return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #fopen #examples
ADD COMMENT
Topic
Name
2+1 =