在下面的程序中,我打算将文件中的每一行读入一个字符串,分解字符串并显示单个单词。我面临的问题是,程序现在只输出文件中的第一行。我不明白为什么会这样?
#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<<" ";
}
}
}