Code:char* cFileIO::readStringFromFile() { string line; getline(*readFile, line); char str[70]; strcpy(str, line.c_str()); printf("%s\n", str); char* tosaveto = str; return tosaveto; }
When I call push_back(t), the string gets mangled. The first time I printf it it's fine, but the second time it's mangled. Anyone have any ideas?Code:for(int x=0; x<map->numCountries; x++) { char* t = readStringFromFile(); printf("%s\n", t); map->countryNames.push_back(t); printf("%s\n", map->countryNames[x]); map->countryRects.push_back(readRectFromFile()); }
The rectangle vertices come out printed fine, it's just the char*s that don't.




Reply With Quote