jit_singh_tara
Full Member level 6
- Joined
- Dec 22, 2006
- Messages
- 325
- Helped
- 9
- Reputation
- 18
- Reaction score
- 4
- Trophy points
- 1,298
- Location
- Delhi , India
- Activity points
- 4,295
Dear friends ,
I need to put some variables (unsigned char , unsigned int , unsigned long int ) type into a string which i will transmit via uart.
For example :
if a(unsigned int) = 987; // value will not exceed 999
b(unsigned long int) = 89997; // value will not exceed 99999
string has to be like : "#S98789997$" //#S has to be the header and $ the footer in the string
if the data value is less :
i.e if a = 45;
b = 783;
then the string should have zeroes in place of blank spaces i.e
string should be like : "#S04500783$"
please suggest what logic should be implemented to do the same .I am using pic mcu , mikroc 5.2.0 compiler .
Basically i need to put variables in the string with zeroes .
I need to put some variables (unsigned char , unsigned int , unsigned long int ) type into a string which i will transmit via uart.
For example :
if a(unsigned int) = 987; // value will not exceed 999
b(unsigned long int) = 89997; // value will not exceed 99999
string has to be like : "#S98789997$" //#S has to be the header and $ the footer in the string
if the data value is less :
i.e if a = 45;
b = 783;
then the string should have zeroes in place of blank spaces i.e
string should be like : "#S04500783$"
please suggest what logic should be implemented to do the same .I am using pic mcu , mikroc 5.2.0 compiler .
Basically i need to put variables in the string with zeroes .