View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
2 dimensional Const char ? |
Posted: Sat Aug 15, 2009 6:06 am |
|
|
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:
and
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
|
|
Posted: Sat Aug 15, 2009 6:26 am |
|
|
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
|
|
Posted: Sat Aug 15, 2009 9:20 am |
|
|
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
|
|
Posted: Sat Aug 15, 2009 6:01 pm |
|
|
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
|
|
Posted: Sat Aug 15, 2009 6:23 pm |
|
|
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
|
|
Posted: Sat Aug 15, 2009 6:29 pm |
|
|
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
|
|
Posted: Sat Aug 15, 2009 6:48 pm |
|
|
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 |
|
|
|