We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I use a AT89S52 and programming with KEIL C51.How can I implement a look-up table for string ? My array example : array[0] = "ABC" array[1] = "Hello" array[2] = "Good morning" array[3] = "Good night"
This is a plain, standard, basic 'C' programming issue - nothing specifically to do with Keil. Try a 'C' textbook. My array example : array[0] = "ABC" array[1] = "Hello" array[2] = "Good morning" array[3] = "Good night" Yes, fine - where's the problem?
Hi I need to setup look-up table for string of day like this const char DayStr[7] = {{"Sunday"}, {"Monday"}, . . {"Saturday"}}; function Int2Day(unsigned char day) { return DayStr[day]; } Thank again
Do you understand how 'C' handles strings? Do you understand how to define a function in 'C'? These are basic 'C' issues - nothing specifically to do with the Keil tools. You need to study a 'C' textbook. Hint: 'C' does not have a function keyword - that's Pascal!
Just to pick a nit what do you mean by array[0] = {"ABC"}; Do you mean to write array0[] = {"ABC"}; Bradford
Try const char *DayStr[7] = {{"Sunday"}, {"Monday"}, . . {"Saturday"}}; Or a 2 dimentional array.
"Just to pick a nit what do you mean by array[0] = {"ABC"};" He didn't write the curly braces; he actually wrote:
array[0] = "ABC"
"That would be a definition (with initialisation) of an array of chatacters..." Actually, it wouldn't quite be that - because the type specification is missing!
"You need to study a 'C' textbook." If you are already a Pascal programmer, 'C' isn't really all that different. The C Programming Language (2nd Edition) by Brian W. Kernighan & Dennis M. Ritchie (Prentice Hall) should be sufficient for you. http://www.amazon.co.uk/exec/obidos/ASIN/0131103628/qid=1123320611/sr=1-1/ref=sr_1_10_1/202-7712637-9820637
Thank for all reply.