Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C compiling: "error: expected expression before"

Status
Not open for further replies.

billy1

Technical User
Joined
Sep 16, 2002
Messages
73
Location
IE
Hi all,
This is my simple ansi C code:
int x, MAT[9]={};
x = nodeinfo.nodenumber;
switch(x) {
case '0':MAT[] = {1,1,2,1,0,0,0,0};
break;
case '1':MAT[] = {1,1,2,2,3,1,0,0};
break;
case '2':MAT[] = {1,2,2,1,0,0,0,0};
break;
default:printf("no node available\n");
}

But I'm getting this compiling error:

xx.c:12: error: expected expression before ‘{’ token
xx.c:13: error: expected expression before ‘{’ token

Can you please let me know what is wrong?

thanks.
 
Which line of code is line 12?

x is an int, but in the switch you're comparing it against literal characters. That's probably what it's complaining about.
 
Thank you both Cpjust and Salem!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top