Sunday, July 12, 2009

Why am I getting a syntax error for this C code?

I am trying to print a linked list of characters...


this function is to print the linked list


and it is saying this when I compile, error: syntax error before ';' token


on the line that reads: printf("%c ", pwalker-%26gt;data.key);








the entire function is as follows











void print (NODE* listtop)


{





NODE* pwalker;





pwalker = listtop;





printf("\nList Contains:\n");





while(pwalker)





(


printf("%c ", pwalker-%26gt;data.key);





pwalker = pwalker-%26gt;link;


}


printf("\n");


return;





}

Why am I getting a syntax error for this C code?
solution: reinstall software and hardware or maybe reinstall windows or mac. and don't install the software for your printer and let windows and mac do that for you. if you still keep getting that problem after that attempts I suggest to dispose of your old printer and get a new one.
Reply:while(pwalker)


(





Should be a brace:





while(pwalker)


{
Reply:while(pwalker)





(


printf("%c ", pwalker-%26gt;data.key);











Should be





while(pwalker)





{ // Wrong brace here


printf("%c ", pwalker-%26gt;data.key);
Reply:If this is an exact copy of your code, then it's the parantheses just before the printf. It should be a bracket.


No comments:

Post a Comment