-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFileop.c
46 lines (42 loc) · 938 Bytes
/
Fileop.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
35
36
37
38
39
40
41
42
43
44
45
46
// Online C compiler to run C program online
#include <stdio.h>
#include <stdlib.h>
void fnRead(FILE*);
void fnWrite(FILE*);
void main(void)
{
FILE *fp1,*fp2;
int choice;
int f=1;
while(f==1){
printf("1. Read \n2.Write\n3.Exit");
printf("Enter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
fp1=fopen("test1.txt","r");
fnRead(fp1);
fclose(fp1);
break;
case 2:
fp1 = fopen("test1.txt","a+");
fclose(fp1);
break;
case 3:
f=0;
}
}
}
void fnRead(FILE *Source)
{
char c;
while((c= getc(Source))!= EOF)
printf("%c",c);
}
void fnWrite(FILE *Source)
{
char c;
while((c=getc(Source))!='q')
putc(c,Source);
}