A
Aman
Hi,
wrote this piece of code on SunOS 5.9 , compiler g++ 2.95.3
trying to see the byte order of an int or short int by converting to
char* . doesn't work . the char* cpt doesn't seem to be initialized !!.
why would that be ?
int main()
{
int x=0x01020304 ;
int* ipt = &x ;
cout << "ipt : "<< hex << ipt << endl ; // ok ---
char* cpt = reinterpret_cast<char*>(ipt) ;
cout << "cpt : " << hex << cpt <<endl ; // NO output for cpt !!!
short int* spt = reinterpret_cast<short int*> (ipt) ;
cout << "spt : " << hex << spt <<endl ; // ok ---
}
regards,
Aman.
wrote this piece of code on SunOS 5.9 , compiler g++ 2.95.3
trying to see the byte order of an int or short int by converting to
char* . doesn't work . the char* cpt doesn't seem to be initialized !!.
why would that be ?
int main()
{
int x=0x01020304 ;
int* ipt = &x ;
cout << "ipt : "<< hex << ipt << endl ; // ok ---
char* cpt = reinterpret_cast<char*>(ipt) ;
cout << "cpt : " << hex << cpt <<endl ; // NO output for cpt !!!
short int* spt = reinterpret_cast<short int*> (ipt) ;
cout << "spt : " << hex << spt <<endl ; // ok ---
}
regards,
Aman.