Though ,not a good approach but the following approach does work.(if your input contains texts which are separated by more than a couple of newlines,expect some unexpected characters in the output)
Inside the while loop
while (getline(filename, line)) //Loop through lines
{
char str[BUFSIZ] ;//BUFSIZ
// already defined in stdio.h
for(int i=0;line[i];++i)
str[i]=line[i];
char * pch=NULL;
pch = strtok (str," ");
while (pch!=NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ");
}
}
Last edited by zalezog; Jan 14th, 2009 at 4:13 pm.