[問題] Xcode v.s. Visual Studio 2008
今天早上在學校用Visual Studio 2008 寫程式
以下是code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
char answer;
string first;
string middle;
string last;
string name;
string age;
char sex;
ofstream fout("output.txt");
fout << "Name" << setw(16) << "Age" << setw(8) << "Sex" << endl;
for(int i=0; i<3; i++)
{
cout << "Does the employee have middle name (Y/N)?" ;
cin >> answer ;
cout << "Input the emplyee's name, age, and sex (M/F): " ;
if (answer=='Y')
{
cin >> first >> middle >> last >> age >> sex;
name = first + ", " + middle + " " + last;
fout << name << setw(20-name.length()) << age
<< setw(10-age.length()) << sex << endl;
}
if (answer=='N')
{
cin >> first >> last >> age >> sex;
name = first + ", " + last;
fout << name << setw(20-name.length()) << age
<< setw(10-age.length()) << sex << endl;
}
}
return 0;
}
發現一件很奇怪的事情...
我早上用這個code可以輕易做到助教的要求,
但回到家,發現!!!
code裡面說要輸入三個name, age, sex 之後
output.txt檔才會完整...
在學校跑都ok
但是在家裡跑卻...(在終端機跑過專案了,也確實打過那些資料)
只fout了「fout << "Name" << setw(16) << "Age" << setw(8) << "Sex" << endl;」
這段code的東西。
我後來cin的資料都沒有顯示在output.txt檔中...
不知道該如何處理?
不行的話...我就要在paralel(不確定拼法對不對啦)灌個VS2008來取代Xcode了...
雖然我覺得Xcode漂亮多了!!
感謝大大~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.160.31
推
04/01 23:15, , 1F
04/01 23:15, 1F
推
04/02 00:21, , 2F
04/02 00:21, 2F
→
04/02 22:07, , 3F
04/02 22:07, 3F
→
04/02 22:07, , 4F
04/02 22:07, 4F
推
04/03 01:16, , 5F
04/03 01:16, 5F
→
04/03 01:16, , 6F
04/03 01:16, 6F
→
04/03 23:16, , 7F
04/03 23:16, 7F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章