-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBCTlec29.c
71 lines (51 loc) · 1.25 KB
/
BCTlec29.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// BCT LECTURE 29
// File Advanced (Complete)
#include<stdio.h>
int main(){
/*
FILE *fp;
fp = fopen("data.txt", "r");
// Read all data from a file...
int c;
while (1){
c = fgetc(fp);
if(c == EOF){
break;
}
printf("%c",c);
} */
// Count the Vowel,Consonant, and Spaces......
/* int c;
int cCounter = 0, vCounter = 0, sCounter = 0;
while (1){
c = fgetc(fp);
if(c == EOF){
break;
}
if(c == 32 || c == 10){
sCounter++;
} else if(c == 'a' ||c == 'e' || c=='i'||c=='o'||c=='u'){
vCounter++;
}else if(c == 'A' ||c == 'E' || c=='I'||c=='O'||c=='U'){
vCounter++;
} else {
cCounter++;
}
}
printf("Vowels: %d\n", vCounter);
printf("Consonant: %d\n", vCounter);
printf("Space and Newline: %d\n", sCounter); */
// Donation List................
FILE *fp;
fp = fopen("donation.txt", "w+");
char name[30];
int donation = 0, i;
for (i = 0; i < 5; i++){
printf("please,Enter your name:\n");
scanf("%s",name);
printf("Enter amount:\n");
scanf("%d", &donation);
fprintf(fp, "%s %d\n", name, donation);
}
return 0;
}