Update: I got the program to read the file and I did this 2-3 days after my last post to this thread. I've been offline. One "gotcha" was that I wanted to use "istringstream" but it seems that the correct thing to use was "stringstream". I can now work with my data.
So I've got the output working. My map editor can create a text file that looks like this:
100 x 300 [1]
400 x 50 [2]
450 x 50 [2]
Each object has its x & y placed in the file, along with its 'type' - at this stage, either a grass texture or a wall.
The problem is that I can't pass a string to the class constructor because it only takes int. Also, I can't change x and y to be string because then I'd never be able to perform calculations on it. Currently I've tried using c_str() and I read in each character, one at a time. After that there's a problem, because I can't have an array that stores '1' '0' '0' because that would be 3 integers, and I don't think integers can be concatenated to get '100'.
I tried using atoi but there's something not right about it:
int value = 0;
std::string bobb = "2309";
value = atoi( bobb );
std::cout( "Function: atoi( \"%s\" ) = %d\n", bobb, value );
and I get:
||=== Build: Debug in mappy (compiler: GNU GCC Compiler) ===|
C:\Users\jeff\Documents\mappy\main.cpp||In function 'int SDL_main(int, char**)':|
C:\Users\jeff\Documents\mappy\main.cpp|62|error: cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'int atoi(const char*)'|
C:\Users\jeff\Documents\mappy\main.cpp|63|error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (const char [29], std::string&, int&)'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
What's the deal with that? I thought c++ could convert a string really easily. Do I need to use pointers, and go indirectly?