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

Assigning values to an array...

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



Joined: 16 Dec 2005
Posts: 22

View user's profile Send private message

Assigning values to an array...
PostPosted: Sat Jul 07, 2007 7:42 pm     Reply with quote

Hi all,

how can u assign hex values to an array?

is the ff. code valid?

Code:
int myArray[30];

myArray = 0x01,0x02,0x03,0x04 ... 0x1E;


how do u do it?

thanx...

Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 07, 2007 9:53 pm     Reply with quote

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=29142


Also, when you have a series of questions on a certain topic
such as arrays, you can post your question to the existing thread.
You don't have to start a new thread each time.
aldinlapinig



Joined: 16 Dec 2005
Posts: 22

View user's profile Send private message

Thanx...
PostPosted: Sun Jul 08, 2007 6:09 am     Reply with quote

thank you very much PCM programmer. i looked at the link that you gave me but is there another way of assigning values to the array without declaring another array as constant? My purpose is to save RAM. I have so much data to send out from the PIC. I want to do it using arrays instead of having a long series of PUTC's in my program. Thank you so much for your immediate response. It is highly appreciated.

Smile

-=alDin=-
Ttelmah
Guest







PostPosted: Sun Jul 08, 2007 9:29 am     Reply with quote

At the end of the day, the values have to be stored somewhere...
You can declare an array at initialisation, with the standard:

int array[10] = {1,2,3,4,5,6,7,8,9,10};

Using hex values, but the compiler will still effectively generate a constant array, and just automatically copy it to RAM for use at the start of the code.
Declaring a number of constant arrays, and copying just the one you want to RAM when needed, allows a single RAM area to be used, rather than multiple areas, but obviously the constant arrays have to exist to hold the values. They only use ROM though, not RAM.

Best Wishes
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