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

Pointer to const string problem

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








Pointer to const string problem
PostPosted: Mon Oct 20, 2008 1:51 am     Reply with quote

Hi to all.
I am trying to set up a pointer to a constant string , but it won't compile. I did it as shown in the documentation , but no luck.
Any ideas what I'm doing wrong.
Here is the code. The uncommented code works fine(strings stored in RAM) ,
but if I try and store them in ROM (commented out code) it won't compile.
Cheers
Rob


Code:



#use delay(clock=16000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7 , bits=8, parity=N ,errors)
#fuses HS,NOWDT,NOPROTECT,NOPUT,BROWNOUT,NOLVP


#include <stdio.h>
#include <string.h>

 char message1[]={"Some text"};
 char message2[]={"Some other text"};
 char *ptr1;

/*
const char message1[14]={"Some text"};
const char message2[15]={"Some other text"};
const char *ptr1;
*/

//---------------------------------------------------------MAIN---------------------------------------------------------------------

void main (void)
{
   


}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 20, 2008 11:24 am     Reply with quote

See this post for one method:
http://www.ccsinfo.com/forum/viewtopic.php?t=34682&start=4
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