CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

newbie question about pointer address in CCS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
huyespo
Guest







newbie question about pointer address in CCS
PostPosted: Mon Apr 19, 2004 9:23 pm     Reply with quote

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








PostPosted: Mon Apr 19, 2004 11:21 pm     Reply with quote

Hmm, not sure CCS supports C++ routines such as COUT. Does it? What is the #include in this case?

Good luck,

Smile Robert
huyespo
Guest







PostPosted: Mon Apr 19, 2004 11:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 20, 2004 2:21 am     Reply with quote

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







PostPosted: Tue Apr 20, 2004 1:41 pm     Reply with quote

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,
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group