char* gets mangled when push_back'd

1
2
3
4
5
6
7
8
9
10
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;
}



1
2
3
4
5
6
7
8
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());
   }


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?


Edit for th 23940234th time : The rectangle vertices come out printed fine, it's just the char*s that don't.
Last edited on
Sorry, double post.
Last edited on
Topic archived. No new replies allowed.