2013-04-07 06:24 PM
2013-04-07 07:14 PM
libraries are from olimex
2013-04-07 07:19 PM
Yeah, doing arithmetic on character arrays probably not a good plan, use something like strcat()
2013-04-07 07:21 PM
2013-04-07 09:48 PM
2013-04-08 01:03 AM
Hi Neil, Clive
please see attachement from one of the replies2013-04-08 04:02 AM
(char *)0x65 represents a string pointer at address 0x65, usually a shadow of your FLASH image, and likely containing junk characters.
char buffer[32], scratch[16]; strcpy(buffer,''this''); strcat(buffer,''that''); // >> ''this that'' strcpy(buffer,''12345''); strcat(buffer,''67890''); // >> ''1234567890'' strcpy(buffer,''number is ''); strcat(buffer,itoa(123, scratch, 10)); // >> ''number is 123''2013-04-08 09:47 AM
Hi Clive!
Thank you very much! itoa didn;t work for me so I tried some reading anf able to come up with this....for (int ctrStart = 0; ctrStart<4; ctrStart++)
{
char message[21], data[1];
strcpy(message,'' WILL START IN:''); //FIRST MESSAGE
snprintf(data, 10,''%d'',hsec1--); //CONVERTING VARIABLE INTO TEXT
strcat(data, '' '');
strcat(message,data); //COMBINING MESSAGE AND VARIABLE
SendValues (0, ''ICE KING ENTERPRISES''); //SendValues (Line number, 20 Character values);
SendValues (1, '' ''); //SendValues (Line number, 20 Character values);
SendValues (2, ''--------------------''); //SendValues (Line number, 20 Character values);
SendValues (3, buffer); //SendValues (Line number, 20 Character values);
Delay(0XFFFFF);
}
Again Thank you for you help! I've learned many things from you
2013-04-08 10:00 AM
data[1]
Seems a tad small an allocation to do the job?
2013-04-08 11:32 AM
As clive1 says,
data[1]
is broken!! But why mess about with all that concatenating anyhow? Why not just do it in one go:#define MAX_MSG_LEN 21 // Max length of a message
char message[MAX_MSG_LEN+1]; // Size to hold a max-length message + NUL terminator
snprintf( message, MAX_MSG_LEN, '' WILL START IN: %d '', hsec1-- );
Note the use of a symbolic constant rather than repeated ''Magic Numbers'' - now only one edit is required to change the maximum message length...