View previous topic :: View next topic |
Author |
Message |
huyespo Guest
|
newbie question about pointer address in CCS |
Posted: Mon Apr 19, 2004 9:23 pm |
|
|
I tried to initialize a pointer by:
int main ()
{
char cell[4]="abc";
char * ptr;
ptr = &cell[3];
*ptr-- = 'e';
cout << "\n cell[2] = " << cell[2] << " / cell[3] = " << cell[3]<<" ";
return 0;
}
However, when compiling, CCS PCW always give an error:
"Expecting a ("
Where did I do it wrong?
Thanks! |
|
|
Guest
|
|
Posted: Mon Apr 19, 2004 11:21 pm |
|
|
Hmm, not sure CCS supports C++ routines such as COUT. Does it? What is the #include in this case?
Good luck,
Robert |
|
|
huyespo Guest
|
|
Posted: Mon Apr 19, 2004 11:38 pm |
|
|
thanks Robert. I should have cut the "cout" part. but it gives the same error. I am just not sure how the "&" get address operator is used in CCS(v3.048). Couldn't find example from online help. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Apr 20, 2004 2:21 am |
|
|
I compiled your code (without the cout) in my PCH 3.187 and it worked fine.
Just to be sure, delete the line which you think generates the compile error. Compile again and see whether the error is gone. To my surprise the error often is still there because the CCS compiler messages are wrong and point you in the wrong direction. Be careful to check the line above the line pointed to by the error message. Pay extra attention to #include files you might have there.
You are using a very old version of the compiler, maybe it is something fixed in the newer versions? But this is some basic functionality, so I wouldn't think so. |
|
|
huyespo Guest
|
|
Posted: Tue Apr 20, 2004 1:41 pm |
|
|
Thanks ckielstra! I will try a newer version of CCS in once I have it. Yes, the most frustrating thing about CCS is that the error messages are not very informative, this could be a headache for someone like me who just started to write c code for PICs.
Cheers, |
|
|
|