#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream fin("test.txt", ios::in);
char line[100000] = { 0 };
char* delim1 = " ";
char filename[20] = "test.txt";
while (fin.getline(line, sizeof(line)))
{
char* tmp;
tmp = strtok(line, delim1);
while (tmp != NULL)
{
printf("%s\n", tmp);
tmp = strtok(NULL, delim1);
}
}
getchar();
}
处理文件
结果