GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-May-2004, 07:41
small_ticket small_ticket is offline
Junior Member
 
Join Date: May 2004
Posts: 45
small_ticket is on a distinguished road
Exclamation

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:
int eastsearch(char **m,int r,int c,char **word,int i,unsigned int k);
int eastsearch(char **m,int r,int c,char **word,int i,unsigned int k)
{

	if(k==strlen(*word))
		return 1;
	if(m[r][c]==word[i][k])
		return eastsearch(m,r,c+1,word,i,++k);
	else 
		return 0;
}

Code:
error C2143: syntax error : missing ';' before 'type' error C2065: 'm' : undeclared identifier error C2065: 'r' : undeclared identifier error C2109: subscript requires array or pointer type error C2109: subscript requires array or pointer type error C2065: 'word' : undeclared identifier 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 ' 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
Last edited by admin : 23-May-2007 at 05:05. Reason: Please use [c] & [/c] to highlight c-syntax
  #2  
Old 15-May-2004, 07:51
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
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:
Originally Posted by small_ticket
error C2143: syntax error : missing ';' before 'type'

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  
Old 15-May-2004, 08:18
small_ticket small_ticket is offline
Junior Member
 
Join Date: May 2004
Posts: 45
small_ticket is on a distinguished road

the whole code


i 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
Attached Files
File Type: txt wordfinder.txt (13.6 KB, 443 views)
  #4  
Old 15-May-2004, 08:59
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,435
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
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
__________________

Definition: Politics
Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
  #5  
Old 15-May-2004, 09:24
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
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:
while(c==" ");

Needs to be changed to:
CPP / C++ / C Code:
while(c==' ');

c is a char so you need to compare it with a char not a string literal

Cheers,
d
  #6  
Old 15-May-2004, 09:40
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by small_ticket
i 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

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  
Old 15-May-2004, 11:59
small_ticket small_ticket is offline
Junior Member
 
Join Date: May 2004
Posts: 45
small_ticket is on a distinguished road
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 19:23
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 10:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 20:30
C++ PhoneBook marita C++ Forum 46 12-Jun-2005 12:10

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:56.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.