123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program to count the number of words in an input text file.

--------------------------------------------------------------------------------



#define NULL 0
FILE *fpt;
void main()
{

char name[20],c;
int nw=0;
clrscr();
printf("Enter the name of file to be checked:- ");
gets(name);
fpt=fopen(name,"r");
if (fpt==NULL)
{
printf("
ERROR - can/'t open file %s",name);
getch();
exit(0);
}
else
{
while ((c=getc(fpt))!=EOF)
{
switch(1)
{
case 1:
if (c==' ')
{
point: // do
// nw=nw+1-1;
while((c=getc(fpt))==' ');

if (c!=' ')
nw=nw+1;
if(c=='
')nw--;
}


// case 3:
if(c=='
'){
goto point;}

}
}
}
printf("

The no. of words in %s is %d. ",name,nw);
getch();
}
 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG