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

Two dimensional array

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



Joined: 07 Jan 2004
Posts: 22
Location: Frankfurt, Germany

View user's profile Send private message Send e-mail

Two dimensional array
PostPosted: Tue Mar 08, 2005 2:42 pm     Reply with quote

Hi folks,

can anybody reveal me how to initialize an two dimensional array?

For a menu-driven application i like to store all the text-strings into such an array and retrieve it via the first dimension as follows:

static constant char text[][] = {1,2,3,4,5...},{"Hello","Welcome","Wait",
"Your Code","...",....};

Butjavascript:emoticon('Mad') the compiler does not like it and the manual does not say anything about it.

Therefore i am asking for your help.

Saludos

Jorge
_________________
dl 2 kp
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 08, 2005 3:00 pm     Reply with quote

If you have a question about compiler behavior, the easiest way
to answer it is to write a test program and examine the .LST file
or look in the Program Memory window in MPLAB. Example
of two dimensional array in ROM:
Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

const char messages[5][10] = {"Hello", "ABC", "12345", "World", "Today"};

//============================
main()
{
char c;
char i;
char j;

c = messages[i][j];

while(1);
}
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Mar 08, 2005 3:42 pm     Reply with quote

Looks like you are wanting pointers to consts again. Remember that they are not supported for this compiler.
Guest








two dim array
PostPosted: Wed Mar 09, 2005 2:12 am     Reply with quote

Hi Mark,

thanks for reply. No, this is what I learned already. It was the way how to initialize the two dimensions. Through your example it is clear now. Unfortunately the manual was not very helpful.

Saludos
Jorge
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