-
Notifications
You must be signed in to change notification settings - Fork 1
/
file_revision_reading.c
74 lines (52 loc) · 916 Bytes
/
file_revision_reading.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
72
73
74
#include<stdio.h>
#include<stdlib.h>
// Global Variable
//File Pointer
FILE *fp;
//check_vowels
int vowels(char x){
if(x=='a'||x=='e'||x=='i'||x=='o'||x=='u')
printf("\nIt\'s a Vowel\n");
else
printf("\nIt\'s a Consonant\n");
return 0;
}
//fgetc() function
int file_fgetc(){
//Variable
char c;
//Check if file Exists
if(fp!=NULL){
printf("\n File Opened Successfully \n");
//Reading
while(1){
//fgetc() function
c=fgetc(fp);
//Check for End of File(EOF) i.e '-1'
if(c==EOF){
break;
}
//Vowels check
vowels(c);
//output
printf("%c",c);
}
}else{
printf("\nFile Doesn\'t Exists !!!\n ");
}
return 0;
}
int main(){
//Variable
char fileName[100];
//Accept File Name
printf("Enter File Name : ");
scanf(" %s",fileName);
//Opening File
fp=fopen(fileName,"r");
//Functions
file_fgetc();
//Exit/Close
fclose(fp);
return 0;
}