プログラムの説明:「names.txt」から「FirstLast」の形式で名前のリストを読み取ります。家系の名前、次に名に基づいて、人々の名前の一般的なアルファベット順に基づいて名前を並べ替えます。ソートされたリストを「sortednames.txt」というファイルに「Last、First」の形式で書き込みます。
これが私のコードです:ファイルデータはフルネーム配列に保存されていましたが、配列の名前と名前を反転する方法に固執していますか?
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;
}