Answer to Question #17431 in C++ for Vipul

Question #17431
Write a program that reads a file, breaks each line into words, strips whitespace and punctuation from the words, and converts them to lowercase
1
Expert's answer
2012-10-29T11:13:28-0400
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<ctype.h>
int main()
{
FILE*f;
charname[50],*pch,*pch1;
charch[100];
f=fopen("sample.txt","r");
if(f==NULL)
{
printf("
File Not Found ");
getch();
exit(0);
}
while(fgets(ch,sizeof(ch),f))
{
pch=strtok(ch,",.-");
while(pch!=NULL)
{
printf("%s
",pch);
pch=strtok(NULL,",.-");
}
}
getch();
return0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS