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

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.

Edited 4 Years Ago by Ancient Dragon

#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

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...

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.

This article has been dead for over six months. Start a new discussion instead.