Pages: 1 [2]   Go Down
Author Topic: Split a string into two integer values  (Read 1020 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49384
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
char* S_message::toString(void)
{
  snprintf(buffer,sizeof(buffer),"%1u",
      temp_reading >> 8//,
     // ( temp_reading & 0xFF ) * 100 / 256,
   //   voltage_reading >> 8
    //  ( voltage_reading & 0xFF ) * 100 / 256
      );
  return buffer;
 
}
Return a pointer to a global variable. Why?

Code:
char* S_message::volts(void)
{
  snprintf(buffer,sizeof(buffer),"%1u",
   //temp_reading >> 8,
     // ( temp_reading & 0xFF ) * 100 / 256,
      voltage_reading >> 8
    //  ( voltage_reading & 0xFF ) * 100 / 256
      );
  return buffer;
Ditto.

Converting the high order byte to a string, discarding the low order byte, and then converting that string back to an int makes no sense.

But, heh, it's your code.
Logged

UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it's not my code, it's what I hacked from the sensornet example, I 'm still not really sure whats going on to be honest. I'm still learning
Logged

Pages: 1 [2]   Go Up
Jump to: