Write To File C

[Solved] Write To File C | Vb - Code Explorer | yomemimo.com
Question : write in file in c

Answered by : josejuanse

#include<stdio.h>
int main(){	FILE *out=fopen("name_of_file.txt","w");	fputs("Hello File",out);	fclose(out);	return 0;
}

Source : | Last Update : Thu, 07 May 20

Question : read files in c

Answered by : josejuanse

#include<stdio.h>
int main(){	FILE *in=fopen("name_of_file.txt","r");	char c;	while((c=fgetc(in))!=EOF)	putchar(c);	fclose(in);	return 0;
}

Source : | Last Update : Thu, 07 May 20

Question : Read Write in File in C language

Answered by : muhammad-abdullah-jxze1et1y350

//////WRITE
#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;
}
//////READ
#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 : | Last Update : Mon, 03 Oct 22

Question : write to file in c programming

Answered by : stupid-shrike-iejojj9s7thy

 [...] printf("Enter name: \n"); if (fgets(name, sizeof name, stdin)) { fputs(name,fileptr); fclose(fileptr); printf("File write was successful\n"); } else { printf("Read error.\n"); }

Source : https://stackoverflow.com/questions/8115218/writing-user-input-to-a-file-in-c | Last Update : Sun, 16 May 21

Answers related to write to file c

Code Explorer Popular Question For Vb