1#include<stdio.h>
2int main(){
3 FILE *out=fopen("name_of_file.txt","w");
4 fputs("Hello File",out);
5 fclose(out);
6 return 0;
7}
1/*Program to read from file using getc() function*/
2#include <stdio.h>
3int main() {
4 FILE *fp;
5 char ch;
6 /*Open file in read mode*/
7 fp= fopen ('example.txt', 'r');
8 while( (ch = getc(fp)) != EOF) {
9 /*getc() function reads a character and its value is stored in variable 'ch' until EOF is encountered*/
10 printf('%ch', ch);
11 }
12 fclose(fp);
13 return 0;
14}