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 support@ccsinfo.com

2 dimensional Const char ?

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



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

2 dimensional Const char ?
PostPosted: Sat Aug 15, 2009 6:06 am     Reply with quote

Simple question:

I want to declare a - where "want" is more like "what the compiler takes"

Code:
Const char Table[8][7] = { "LED1 0", "LED1 1", "LED2 0", "LED2 1", "LED3 0", "LED3 1", "LED4 0", "LED4 1"};

logic tells me that:
Code:

Table[2][0] == 'L'

and
Code:
Table[5][4]=='3'

why is the second field [7] instead of [6]?

Table[8][x] should be equal to one of the strings, which are 6 chars long.

Position-{ 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 }
char-----{ L - E - D - 1 - ' ' - 1 - ? - ? }

WTF?

I don't know if I explained my self correctly...

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Aug 15, 2009 6:26 am     Reply with quote

by the way,

the purpose of this is to find one of those forementioned strings
inside a buffer, which is filled by my serial ISR.

thanks

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
Ttelmah
Guest







PostPosted: Sat Aug 15, 2009 9:20 am     Reply with quote

The strings are _not_ 6 characters long.
A 'string' in 'C', is a _null terminated_ sequence of bytes. You need to count the 'null' as well.
Read a C reference book. This is nothing special to CCS.....

Best Wishes
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Aug 15, 2009 6:01 pm     Reply with quote

hi,

thanks for the clarification...taking that into account... my problem still persists

i cant find it.. started a new thread...

thanks anyways...

gabriel
_________________
CCS PCM 5.078 & CCS PCH 5.093
drolleman
Guest







PostPosted: Sat Aug 15, 2009 6:23 pm     Reply with quote

Table[5][4]=='3' is not correct

Table[5][4]==' ' is a space

if you use the debugger you can use the watch on the varibles.
DROLLEMAN
Guest







PostPosted: Sat Aug 15, 2009 6:29 pm     Reply with quote

also there is no such

Table[8][x]

you declared 8 items they are numberd 0 - 7

Table[7] would have "LED4 1" your last entry
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Aug 15, 2009 6:48 pm     Reply with quote

hi

Quote:

Table[5][4]=='3' is not correct

Table[5][4]==' ' is a space

yeah.. I miscounted... I wrote the example code by hand...its not a copy paste....

Quote:

Table[8][x]

you declared 8 items they are numbered 0 - 7

Table[7] would have "LED4 1" your last entry

Again... miscounted...I wrote the post in a hurry... I had to go work and had people waiting for me....

Sorry for that...

Dumb mistake.... its not that way in my code..I check anyways just in case...

Thanks anyways...

Again sorry for the bad post...

Maybe you can help me in my new post.... I'm really stuck.

g
_________________
CCS PCM 5.078 & CCS PCH 5.093
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