In the below program , I intend to read each line in a file into a string , break down the string and display the individual words.The problem I am facing is , the program now outputs only the first line in the file. I do not understand why this is happening ?
#include<iostream>
#include<string>
#include<fstream>
#include<cstdio>
using namespace std;
int main()
{
ifstream InputFile("hello.txt") ;
string store ;
char * token;
while(getline(InputFile,store))
{
cout<<as<<endl;
token = strtok(&store[0]," ");
cout<<token;
while(token!=NULL)
{
token = strtok(NULL," ");
cout<<token<<" ";
}
}
}