![]() |
|
#1
|
|||
|
|||
Error: expected unqualified-id before "if"Hey guys, I am new to c++ programming and i am making this program but i have some errors that i dont really understand what they mean. Please tell me what is wrong about it. The program is originally written in spanish but i traducted but the variables are still in spanish but i think they're easy to understand.
This are the errors i have: 52 - expected unqualified-id before "if" 52 -expected `,' or `;' before "if" 74 -expected unqualified-id before "if" 74 -expected `,' or `;' before "if" 108 -expected constructor, destructor, or type conversion before '(' token 108 -expected `,' or `;' before '(' token 109 -expected unqualified-id before "return" 109 -expected `,' or `;' before "return" 110 -expected declaration before '}' token Here is the code (I marked the line numbers as coments): CPP / C++ / C Code:
I would appreciate any help, I think this is a very simple mistake but because of my lack of experience i dont really understand it. Thx in advance |
|||
|
#2
|
|||
|
|||
Re: Noob needs helpDid you mean to have this closing brace:
CPP / C++ / C Code:
If that is removed things change quite a bit. When first writing a new functions or programs indicate your blocks intentionally like this: CPP / C++ / C Code:
You can always go back and collapse them after the new section is debugged. Also , some editors (like vim) will hightlight both ends of a block when the cursor is over the { or }. That's how I found the closing brace I mentioned above. Very handy. Last edited by Howard_L : 01-Nov-2009 at 00:08.
|
|
#3
|
|||
|
|||
Re: Noob needs helpHey tahnks this really helped me. It was a really fool mistake, so do you recomend me to download the vim editor? Do you know why after i run my program i got this message that only lets me see the result like for half a second?
![]() |
|
#4
|
|||
|
|||
Re: Error: expected unqualified-id before "if"Quote:
Quote:
Quote:
|
|
#5
|
|||
|
|||
Re: Error: expected unqualified-id before "if"I dont really know, the one of the screencshot of my last post
|
|
#6
|
|||
|
|||
Re: Error: expected unqualified-id before "if"You don't know? How can you not know?
Well from that I see that your're using the DevC++ IDE on XP. What does "Presione una tecla para continuar ..." mean? Would it by any chance be "Press a key to continue" ? Is that all you see when you run the program you posted above after taking out the '}' I pointed out in the previous post? Have you successfully run other C++ programs in your DevC setup? Last edited by Howard_L : 01-Nov-2009 at 20:09.
|
|
#7
|
|||
|
|||
Re: Error: expected unqualified-id before "if"Yeah, im alrready able to run a program. But when i run it and get the finall result, it only lets me see it for like half a second and then appears that gray message. Endeed budy, "Presione una tecla para continuar" means "Press a key to continue". Any reason why the gray message appear? Is it my Dev C++ version? Do you know where i can download a different one?
|
|
#8
|
|||
|
|||
Re: Error: expected unqualified-id before "if"Ok, I cranked up my old 98 and DevC 4 and I see now.
Yes the console closes because there is a \n left in stdin from the last cin >> xxx. system("pause") . . sees the leftover \n and thinks you just pressed it and so moves on. You could add a second system("pause") but instead I would recommend you use the C++ "getline() function as it is cross platform where system("pause") is windows only and that any system() call will fork another process which will cause more work for the cpu. (in fact, system("pause") causes my laptop to overheat if left paused for 5 minutes or so!) So try this at the bottom of your prog: CPP / C++ / C Code:
Another option would be running your program in a separate MSDOS console instead of the pop up console DevC uses. I think you will find it in Start > Accessories. Then you will have to navigate to the directory your prog.exe is in. That way the console will be left open for you to look over your last output as long as you want and you wouldn't even need any of the pause stuff at all. Type exit to close it when you're all done. Last edited by Howard_L : 01-Nov-2009 at 23:49.
|
|
#9
|
|||
|
|||
Re: Error: expected unqualified-id before "if"Hey sorry for asnwering late, i've been busy this last days. Thanks a lot for this information, it really worked an now it lets me see the result of my program as long as i want. Thx a lot a gain.
|
Recent GIDBlog
Enable Compression for SSH by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help a noob | c_noob | C Programming Language | 1 | 09-Nov-2007 12:20 |
| Total Noob needing help | not a banana | C++ Forum | 4 | 04-Jun-2007 18:12 |
| Noob with a question,any help would be greatly appreciated :) | yrostran | C Programming Language | 7 | 11-May-2006 02:44 |
| Noob C++ question | Capnpooh | C++ Forum | 2 | 30-Mar-2006 19:25 |
| Noob question on c arrays and functions | brett | C Programming Language | 1 | 20-Apr-2005 03:59 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The