Answers for "c program to read and write to a file"

C
13

write in file in c

#include<stdio.h>
int main(){
	FILE *out=fopen("name_of_file.txt","w");
	fputs("Hello File",out);
	fclose(out);
	return 0;
}
Posted by: Guest on April-30-2020
3

c program to read and write to a file

/*Program to read from file using getc() function*/
#include <stdio.h>
int main() {
 FILE *fp;
 char ch;
 /*Open file in read mode*/
 fp= fopen ('example.txt', 'r');
 while( (ch = getc(fp)) != EOF) {
  /*getc() function reads a character and its value is stored in variable 'ch' until EOF is encountered*/
  printf('%ch', ch);
 }
  fclose(fp);
  return 0;
}
Posted by: Guest on March-17-2020
0

c open a file and write stuff

FILE *fopen( const char * filename, const char * mode );
Posted by: Guest on October-09-2020

Code answers related to "c program to read and write to a file"

Code answers related to "C"

Browse Popular Code Answers by Language