What do these ifstream errors mean please?
Hi,
i am trying to use ifstream to open a file a user specifys (Sourcode http://pastebin.com/357953). The problem is when i try and compile i get these errors :- g++ gameserverpro11.cpp -o gameserverpro gameserverpro11.cpp: In function `int main()': gameserverpro11.cpp:67: error: jump to case label gameserverpro11.cpp:57: error: crosses initialization of `std::ifstream in' gameserverpro11.cpp:72: error: jump to case label gameserverpro11.cpp:57: error: crosses initialization of `std::ifstream in' gameserverpro11.cpp:76: error: jump to case label gameserverpro11.cpp:57: error: crosses initialization of `std::ifstream in' gameserverpro11.cpp:84: error: syntax error at end of input any help would be much appreciated thankyou. P.s you lot must be getting fed up of me asking by now lol |
That means you defined a new variable within one of your case statements.
The compiler doesn't like that, as some execution paths will skip the initialization of that variable. Move the the variable declaration "ifstream in(filename)" on line 57 to a point above your switch statement, and then use in.open(filename) at line 57 instead to open your file. |
Also, in the future, please try to post relevant code, in [ code ] brackets. :)
|
Is it possible that you forget one '}', or am I missing something?
Two '{' in lines 53 and 58, but only one '}' in line 61. |
Code:
Is it possible that you forget one '}', or am I missing something? It sure looks like he's missing a } somewhere, which probably caused the final error. |
Hi,
yeah i noticed the missing stuff, its one of them things in c or c++ im sure everyone does it when they dont mean to like missing a ;:,"`' out. Since i cant do what i want with ifstream im going try use xtern and make an editor like nano/pico come up for the edit config file part. Thankyou all for your help twirl |
All times are GMT -5. The time now is 03:46 AM. |