Question : fopen function in c
Answered by : sameeraz
#include<stdio.h>
#include<conio.h>
void main(){ FILE *fp; //r means read file fp=fopen("sam.txt","r"); fclose(fp); getch();
}
Source : https://www.youtube.com/channel/UCdVjYe8rEGzNcXgvoNvpLhQ | Last Update : Wed, 24 Mar 21
Question : c fopen
Answered by : enthusiastic-echidna-psn78umeoaz3
#include <stdio.h>
#include <stdlib.h>
int main () { FILE * fp; fp = fopen ("file.txt", "w+"); fprintf(fp, "%s %s %s %d", "We", "are", "in", 2012); fclose(fp); return(0);
}
Source : https://www.tutorialspoint.com/c_standard_library/c_function_fopen.htm | Last Update : Mon, 19 Oct 20
Question : fopen examples in c
Answered by : eyal-amsalem
#include <stdio.h>
#include <stdlib.h>
int main()
{ int num; FILE *fptr; if ((fptr = fopen("C:\\program.txt","r")) == NULL){ printf("Error! opening file"); // Program exits if the file pointer returns NULL. exit(1); } fscanf(fptr,"%d", &num); printf("Value of n=%d", num); fclose(fptr); return 0;
}
Source : https://www.programiz.com/c-programming/c-file-input-output | Last Update : Mon, 24 Jan 22
Question : fopen examples in c
Answered by : muhammad-rizwan-x55rg0nrkwtr
#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 : https://www.programiz.com/c-programming/c-file-input-output | Last Update : Mon, 21 Nov 22