![]() |
|
#1
|
|||
|
|||
Error C2143: syntax error : missing ';' before 'type'I have a piece of code and some errors and warnings I could not understand why they occur. Could you give me your advice?
Thanks all of you have a nice day I am waitting for your responses CPP / C++ / C Code:
Code:
Last edited by admin : 23-May-2007 at 06:05.
Reason: Please use [c] & [/c] to highlight c-syntax
|
|||
|
#2
|
||||
|
||||
|
Hello small_ticket, welcome to GIDForums.
I'd really like to see more of this code to be able to answer this. Alot of times a string of errors like this means that something is f'ed up before your function. This error in particular is the one you should try to find: Quote:
If your code isn't too big, you should try to post a bit more of it. As far as I can tell the other errors are just due to parsing errors after this first error. Fix this one and everything should fall in place. Cheers, d |
|
#3
|
|||
|
|||
the whole codei attached the code it is a little long but the errors occur only in the piece of code that i send before i hope you can help me i am waiting for your response :-) thanks
have a nice day |
|
#4
|
||||
|
||||
|
Well, we have no idea what lines the errors occurred on. The first error about ';' is referencing what line? This problem would be on a previous line most likely.
error C2143: syntax error : missing ';' before 'type' A ';' should be put somewhere error C2065: 'm' : undeclared identifier used 'm' but didn't define 'm' error C2065: 'r' : undeclared identifier used 'r' but didn't define 'r' error C2109: subscript requires array or pointer type error C2109: subscript requires array or pointer type error C2065: 'word' : undeclared identifier used 'word' but didn't define 'word' error C2109: subscript requires array or pointer type error C2109: subscript requires array or pointer type warning C4047: 'function' : 'char ** ' differs in levels of indirection from 'int ' A function was passed a pointer to pointer to char but the definition requires int instead warning C4024: 'eastsearch' : different types for formal and actual parameter 1 warning C4047: 'function' : 'char ** ' differs in levels of indirection from 'int ' warning C4024: 'eastsearch' : different types for formal and actual parameter 4 __________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#5
|
||||
|
||||
|
Okay, it is an error where you don't have as many "}" as you do "{". I added one "}" at the end of the main function and got it to compile, but it is something that you may want to double check on. Somewhere your indenting in your main function got way off.
A suggestion: try to break your next program down into more functions. With these really long functions it gets really difficult to track your opening "{" and closing "}"s. Also, what compiler/editor are you using? I use kwrite in Linux and it highlights your matching brackets. This is very convenient if you have something like this. One more error that I found: CPP / C++ / C Code:
Needs to be changed to: CPP / C++ / C Code:
c is a char so you need to compare it with a char not a string literal Cheers, d |
|
#6
|
|||
|
|||
|
Quote:
Your main() does not have enouogh closing brackets. I deduce from your error messages that you are using Visual C++. If you are using the editor built into the IDE, there is a keyboard shortcut for "GoToMatchBrace". The default is ctrl-]. If you place the cursor before the opening "{" in your main(), and press the ctrl-] combination, nothing happens (there is no matching brace). If you place the cursor before the last "}" in your main(), and press the ctrl-] combination, the cursor jumps back to the opening "{" after your first "if() statement. So --- there's a problem. If you are not using the Visual C++ IDE, then use an editor with some kind of delimiter-matching function (vi uses the "%" key for this) and learn how to use it. You can do this manually as follows: Start with a count of zero. Then, every time your program has a "{", increment the count. Every time your program has a "}", decrement the count. When you reach the end of main(), the count must be zero. (You can also use this for each if(), while(), etc., block statement.) (You can also use this scheme to make sure your expressions have balanced numbers of parentheses.) Anyhow, after getting the brackets right, it's ready to compile, run, and debug. Dave |
|
#7
|
|||
|
|||
|
You asked me which compiler I am using. I am using Microsoft Visual. I have closed the brackets as you said. Now it seems okay.
![]() |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linked Lists advice request | promsan | C Programming Language | 74 | 23-May-2007 09:29 |
| Hard drive/CPU Diagnoses Issues | binarybug | Computer Hardware Forum | 1 | 22-Jan-2007 20:23 |
| Winsock error when compiling FLTK 2.0 Projects | mauriciorossi | FLTK Forum | 3 | 16-Aug-2005 11:18 |
| Help with syntax errors | PeteGallo | C Programming Language | 7 | 08-Aug-2005 21:30 |
| C++ PhoneBook | marita | C++ Forum | 46 | 12-Jun-2005 13:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The