0
Input txt file:
Joe Smith
Mary Jones
Hamid Namdar
Desired Output Txt file:
Smith Joe
Jones Mary
Namdar Hamid
Output file I receive:
SmitJoeJonesMaryNamdarHamid
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
\t ofstream output;
\t ifstream input;
\t string firstname, lastname;
\t output.open("LastName.txt");
\t input.open("FirstName.txt");
\t cout << "Processing Data..." << endl;
\t input >> firstname >> lastname;
\t cout << firstname << lastname << endl;
\t output << lastname << firstname;
\t cout << lastname << firstname << endl;
\t input >> firstname >> lastname;
\t cout << firstname << lastname << endl;
\t output << lastname << firstname;
\t cout << lastname << firstname << endl;
\t input >> firstname >> lastname;
\t cout << firstname << lastname << endl;
\t output << lastname << firstname;
\t cout << lastname << firstname << endl;
\t input.close();
\t output.close();
\t cin.get();
\t cin.get();
\t return 0;
}
我的程序需要有名字之間的空間,即使是我的文本文檔中的空間,不被讀取的空間。有沒有人對我應該做什麼有一個想法,以便讀取空間?
請張貼輸入文件中,預期產出和觀察到的產出。 –