-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMOH4.C
60 lines (60 loc) · 1.17 KB
/
MOH4.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
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main(int argc,char *argv[])
{
FILE *fp;
char ch,file[20];
static int nl,nc,nw,nv;
if(argc<2)
{
clrscr();
printf("$ ");
scanf("%s",file);
fp=fopen(file,"rb+");
if(fp==NULL)
printf("cannot open the file......");
argv[1]=file;
}
if(argc>=2)
{
fp=fopen(argv[1],"rb+");
if(fp==NULL)
printf("cannot open the file......");
}
while((ch=(char )fgetc(fp))!=EOF)
{
if(ch=='\n')
{
nl++;
nc--;
}
if(toupper(ch)=='A' || toupper(ch)=='E' || toupper(ch)=='I' || toupper(ch)=='O' || toupper(ch)=='U')
{
nv++;
}
if(ch==' ' || ch=='\t')
{
nw++;
nc=nc+0;
}
else
nc++;
}
textbackground(BLACK);
textcolor(CYAN);
gotoxy(15,20);
cprintf(" the number of characters in the file %s are: %d",argv[1],nc);
textcolor(RED );
gotoxy(15,21);
cprintf(" the number of lines in the file %s are : %d ",argv[1],nl);
textcolor(MAGENTA);
gotoxy(15,22);
cprintf(" the number of words in the file %s are : %d ",argv[1],nw);
textcolor(YELLOW);
gotoxy(15,23);
cprintf(" the number of vovels in the file %s are : %d ",argv[1],nv);
textcolor(WHITE);
fflush(stdin);
while(!kbhit());
}