我有点想知道如果我失去了我的想法,但我发誓,这个代码输出笑脸作为.name值!世界正在发生什么?到目前为止,它似乎只有在值为1时才有效,其他任何事情都可以正确地给出错误。将不正确的值类型分配给struct属性时的笑脸!
我意识到代码有缺陷 - >我不需要帮助。
#include <iostream>
#include <fstream>
#include <regex>
#include <string>
#include <list>
using namespace std;
using namespace tr1;
struct CollectedData
{
public:
string name;
float grade;
};
int main()
{
string line;
list<CollectedData> AllData;
int count;
ifstream myFile("test_data.txt");
if (myFile.fail()) {cout << "Error opening file"; return 0;}
else
{
cout << "File opened... \n";
while(getline(myFile, line)) {
CollectedData lineData;
lineData.name = 1;
lineData.grade = 2;
AllData.push_back(lineData);
}
}
cout << "\n\n File contents: \n";
list<CollectedData>::iterator Iterator;
for(Iterator = AllData.begin();
Iterator != AllData.end();
Iterator++)
{
cout << "\t" << (*Iterator).name << " - ";
cout << "\t" << (*Iterator).grade << "\n";
}
getchar();
return 1;
}
:-) http://img21.imageshack.us/img21/4600/capturekjc.jpg
我知道这些代码是没用的,
我想知道为什么它给我笑脸INSTEAD错误
欣慰的。 。 。嘲讽
笑脸是字符0x01。 – LiraNuna 2009-08-31 02:35:33
+1,情况和轻微的愤怒让我发笑。 – Corey 2009-08-31 03:02:29
代码表:http://en.wikipedia.org/wiki/Code_page_437#Characters – mark4o 2009-08-31 03:07:09