Write a program that reads a file, breaks each line into words, strips whitespace and punctuation from the words, and converts them to lowercase
please help me out .
thanks in advance

Recommended Answers

All 10 Replies

Help you do what exactly? Start your program that just opens a file then reads it one line at a time. Once you get that compiler without errors and working, you can do the rest of the assignment. Do the assignment one small step at a time and you will have it done in no time.

Your program will need to include stdio.h and string.h, as a minimum.

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
#include<ctype.h>


int main()
{
clrscr();
FILE *f;
char name[50],*pch,*pch1;
char ch[100];
f=fopen("c:\\TurboC++\\Disk\\TurboC3\\sample.txt","r");
if(f==NULL)
{
 printf("\n File Not Found ");
 getch();
 exit(0);
}
while(fgets(ch,sizeof(ch),f))
{
 pch=strtok(ch,",.-");
 while(pch!=NULL)
  {
   printf("%s \n ",pch);
   pch=strtok(NULL,",.-");
  }
}
getch();
return 0;
}

i hav done till dis but its saying FILE NOT FOUND
PLEASE help me out....

paste this into your file manager to test
c:\TurboC++\Disk\TurboC3\sample.txt

or use sameple.txt
and put it in same dir as your exe

use Windows Explorer and check if that file exists. My guess is that there is no such file in that folder.

i hav already created that file in that particular file...
:(

apparently not, otherwise the program would be able to find it. Make sure the spelling is correct.

yes the file name is correct .
and i have tried both the way of writting as sample.txt as well
plzz run it on ur system nd let me knw abt dat...

please try different compiler maybe code blocks IDE or other

Your program worked ok using VC++ 2012 Express. I just created a directory structure like the one in your program and copied a text file named sample.txt. That tells me your problem is either your compiler or the location of the file.

Move sample.txt to c:\ and see if your program works with that. It's possible the path is too long for your compiler or the compiler doesn't like the ++ in the folder name.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.