程序说明: 从“names.txt”中以“First Last”格式读取名称列表。 根据姓氏和名字,根据人名的典型字母顺序对姓名进行排序。 以“Last,First”格式将排序后的列表写入名为“sortednames.txt”的文件中。C++程序的排序名称
这里是我的代码:文件数据存储在全名数组中,但现在我被卡在如何翻转数组中的姓和名?
int main()
{
const int MAXNAMES = 100;
int value = 0;
string fullname[MAXNAMES];
ifstream inFile;
inFile.open("names.txt"); //open the file to excess the rainfall data
if (inFile.fail()) // testing the file
{
cout << "Error opening file. Please check that the file currently `enter code here`exist" << endl;
exit(1);
}
cout << "File successfully open" << endl;
while(!inFile.eof())
{
while(value < 100)
{
getline(inFile,fullname[value]);
value++;
}
}
return 0;
}
确切位置在哪里,你卡住了?你有没有试过在伪代码中写下所需的步骤? –