Hey there.
After several hours fiddling with my latest bit of code, I've finally decided to admit defeat and seek reinforcements, so to speak. There're two problems, both related to my filestreaming, and I'd be very grateful if someone could give me a few pointers (er, advice, that is) in the right direction.
Just so you know, I'm more or less a beginning programmer, using Dev C++, and running Windows XP Home Edition. The code will eventually be a small text-based RPG (I've made one before but it was quite badly-coded; this is 2.0 ).
--------------------------------------------------------------
Problem One:
From that line of code (I think that part is all that this particular problem concerns, and the whole program-in-progress is spread over several files anyway), I'm getting an error:Code:ifstream MapLoad(player.GetLocation());
no matching function for call to `std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(std::string)'
player.GetLocation() returns a string, so I was hoping that the above code would try to open a file with the same name as the value returned by player.GetLocation() for writing to.
I've tried getting the value that player.GetLocation() outputs and saving it to a variable, then putting that in instead, but that didn't work, either. Nor did declaring the filestream (is that the right phrase?) and then opening it separately. I found that putting a plain string in in quotes works, but I need it to look for a file according to the string returned by player.GetLocation(), so that's no good.
I really have no idea why it doesn't like it, so any guidance at all would be helpful.
--------------------------------------------------------------
Problem Two:
A few lines later, once my filestream is (or should...) be open, I try to check what the next character is before doing anything about it.
I want it to 'peek' at the next character, and if it is any of those three seen above, execute the code in the if statement without actually getting it. However, I get the error:Code:if((MapLoad.peek() == "|") || (MapLoad.peek() == "-") || (MapLoad.peek() == "+"))
ISO C++ forbids comparison between pointer and integer
Once for each comparison. I tried get() instead to see if it worked, but no, that didn't work, either. What am I doing wrong? Again, guidance would be appreciated.
--------------------------------------------------------------
If anyone could give me a little help (in English if possible, I don't speak C++ as fluently as I'd like to be able to just yet ), that'd be great.
Thanks in advance!