What am I doing wrong please?
I am getting corrupted strings,
Hitech C, again (still not sure that this could be a compiler issue).
char **days[7];
void main(void){
days[0]="Monday";
days[1]="Tuesday";
days[2]="Wednesday";
days[3]="Thursday";
days[4]="Friday";
days[5]="Saturday";
days[6]="Sunday";
..... /there are no other references to 'days' anywhere in code. time[8] is being set to 0.
lcd_goto(0x00);
//this line
sprintf(out,"%s",days[time[8]]);
//
lcd_puts(out);
lcd_goto(0x40);
sprintf(out,"%c%c:%c%c:%c%c",time[2],time[3],time[4],time[5],time[6],time[7]);
}
So, with the line commented out, the LCD shows:
Line1:
Line2: 21:23:11
With the line uncommented, I get:
Line1: uonday
Line2: 21:23:11
If I print out anything else (i.e., not a variable stored in an array), it comes out fine. (i.e., if I did, char * u="Monday";sprintf(out,"%s",u); it works)
I am getting corrupted strings,
Hitech C, again (still not sure that this could be a compiler issue).
char **days[7];
void main(void){
days[0]="Monday";
days[1]="Tuesday";
days[2]="Wednesday";
days[3]="Thursday";
days[4]="Friday";
days[5]="Saturday";
days[6]="Sunday";
..... /there are no other references to 'days' anywhere in code. time[8] is being set to 0.
lcd_goto(0x00);
//this line
sprintf(out,"%s",days[time[8]]);
//
lcd_puts(out);
lcd_goto(0x40);
sprintf(out,"%c%c:%c%c:%c%c",time[2],time[3],time[4],time[5],time[6],time[7]);
}
So, with the line commented out, the LCD shows:
Line1:
Line2: 21:23:11
With the line uncommented, I get:
Line1: uonday
Line2: 21:23:11
If I print out anything else (i.e., not a variable stored in an array), it comes out fine. (i.e., if I did, char * u="Monday";sprintf(out,"%s",u); it works)