Smiley face when assigning improper value type to struct property!
c++, struct, types, variable-assignment
Solution
The smiling face is the character with ASCII value 1. Not sure why, but apparently your compiler decided to treat it as a char, so you get the smiley.
Problem
I am somewhat wondering if I am losing my mind, but I swear to you, this code outputs smiley faces as the .name values!! what in the world is going on? Thus far it seems to only work when the value is 1, anything else properly gives errors. I realize the code is flawed -> I do not need help with this. ``` #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 I KNOW THAT THE CODE IS USELESS, I WANT TO KNOW WHY IT IS GIVING ME SMILEY FACES INSTEAD OF ERRORS comforting. . . mocking