Hi, is there anything in this function that would cause it to return {1,2,3,4} on one system and {11,12,13,14} on another? Both have the same environment variable of TEST=0xb. When I run it on my computer it gives the correct output: 0xb is translated to 11, found to be odd, and the string {11,12,13,14} is computed.
But when I run it on another computer, somehow I wind up with {1,2,3,4}
I want to make sure I'm not missing something obvious here.
void example()
{
string str;
char temp[11];
int number = 0;
const char *penv = getenv( "TEST" );
number = strtol( penv, NULL, 16 );
if((number % 2) == 1) //Odd #
sprintf( temp, "%d,%d,%d,%d", number, number+1, number+2, number+3);
else
sprintf( temp, "%d,%d,%d,%d", number-1, number, number+1, number+2);
str = temp;
cout << str << "\n";
}
But when I run it on another computer, somehow I wind up with {1,2,3,4}
I want to make sure I'm not missing something obvious here.
void example()
{
string str;
char temp[11];
int number = 0;
const char *penv = getenv( "TEST" );
number = strtol( penv, NULL, 16 );
if((number % 2) == 1) //Odd #
sprintf( temp, "%d,%d,%d,%d", number, number+1, number+2, number+3);
else
sprintf( temp, "%d,%d,%d,%d", number-1, number, number+1, number+2);
str = temp;
cout << str << "\n";
}