data.txt文件内容: a b x c s d f g h w
下面是代码:
#include <iostream>
#include <fstream>
#include<string>
using namespace std;
int main()
{
char num[10];
ifstream file;
file.open("data.txt");
if (file.is_open())
{
file >> num;
}
else
cout << "读取错误!" << endl;
for (int j = 0; j < 10; j++)
cout << num[j] << " ";
file.close();
cin.get();
return 0;
}
输出:
读取错误!
?