If you're only converting one digit, all you have to do is use xyz->data[n] - '0' This will remove the ascii offset of the numbers.
On the other hand, if you're dealing with multiple digits, you might be interested in the standard C "atoi()" function. It will convert an array of characters to the corresponding decimal integer. Hope this helps, Bryn Smith -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of primalfear 69 Sent: Saturday, 30 September 2006 6:01 PM To: tinyos-help Subject: [Tinyos-help] taking ascii value instead the literal value.... hello everybody I am using mica2 with Tinyos1.1.0 under windows XP. my application needs to transmit a stack of data. i am using the TOS_Msg structure........ in that the payload data has our stack in it. (our structure includes the many fields like function etc and then comes byte count.(number of data layers being followed )and then the data). the problem is coming when i try to extract the data using the byte count which i have declared. here is the code if( i == xyz->data[n] ) { do something; } if xyz->data[n] is 5 (the byte count) ........... then the loop is waiting till 53 times in order to "do something". where 53 is the ascii value of 5 in decimal. how to get the check with the literal value instead the ascii. is there any command to convert ascii to literal or some other suggestions..:) Regards Primalfear _______________________________________________ Tinyos-help mailing list [email protected] https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
