This is really weird... I'm trying to put the values in a string manually with a zero first, the iBuffer (the char as binary in a long) works fine if I cout it, but if I output any of the multidimentional array sOutput2 (char sOutput2[1024][7]), it gives me a completely different value... I tried substituting manual changes for itoa, but that doesn't seem to be the problem...
Code:
for (i = 0, iLength = strlen (sOutput); i<iLength; i++)
{
iBuffer = to_binary( int(sOutput[i]) );
if (iBuffer < 1000000) //check to see if there are 7 digits
{
sOutput2[i][0] = '0';
sOutput2[i][1] = char( (iBuffer%1000000)/100000 );
sOutput2[i][2] = char( (iBuffer%100000)/10000 );
sOutput2[i][3] = char( (iBuffer%10000)/1000 );
sOutput2[i][4] = char( (iBuffer%1000)/100 );
sOutput2[i][5] = char( (iBuffer%100)/10 );
sOutput2[i][6] = char( iBuffer%10 );
sOutput2[i][7] = '\0';
}
else if (iBuffer >= 1000000)
{
_itoa(iBuffer,sOutput2[i],7);
}
}
cout << iBuffer << endl << sOutput2[0] << endl;
For example... if I input 'a' into sOutput (not sOutput2), then send it off for binary conversion, the cout line ends up giving me something like
or if I input '0'...
It does that if it is done manually or with itoa! And yes, those are actually smileys in the program, not : ).