I want to store a 4-byte int in a char array... such that the first 4 locations of the char array are the 4 bytes of the int.
Then, I want to pull the int back out o
char a[10]; int i=9; a=boost::lexical_cast(i)
found this is the best way to convert char into int and vice-versa.
alternative to boost::lexical_cast is sprintf.
char temp[5]; temp[0]="h" temp[1]="e" temp[2]="l" temp[3]="l" temp[5]='\0' sprintf(temp+4,%d",9) cout<
output would be :hell9