-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiofunction2.c
34 lines (30 loc) · 1.06 KB
/
iofunction2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
int main()
{
FILE *ptr = NULL;
// ptr=fopen("myfile.txt","r");
// for Reading the text file
// char c=fgetc(ptr);//getc read one charcter only in text file
// printf("%c\n",c);
// c=fgetc(ptr);
// printf("%c",c);
// char array[100];
// fgets(array,90,ptr);//gets read string in text file
// printf("%s",array);
// For writing the text file
// ptr=fopen("myfile.txt","w");
// fputc('o',ptr);//write one charcter only in text file
// fputs("This is ALtaf ",ptr);//write string in text file from start
// for writing and reading both
// ptr=fopen("myfile.txt","r+");//replace word in start in text file
// fputc('o',ptr);
// fputs("This is ALtaf ",ptr);
// ptr=fopen("myfile.txt","w+");//delete all text write word from start text file
// fputc('o',ptr);
// fputs("This is ALtaf ",ptr);
// ptr=fopen("myfile.txt","a+");// write word from last text file
// fputc('o',ptr);
// fputs("This is Aftab ",ptr);
fclose(ptr);
return 0;
}