-2

I am testing following peace of code for possible Endian issue. Code was written for ppc and needs to be run on x86 box now.

string Mac = nodeMessage->getMac();
char mac_string[17];
strncpy(mac_string, Mac.c_str(),16);
AJ.
  • 2,536
  • 9
  • 44
  • 80

3 Answers3

4

Endian-ness of a machine affects integral values that are more than one byte wide. I don't see any integral values there. Hence, I don't see any Endian-ness problems associated with the above code.

R Sahu
  • 200,579
  • 13
  • 144
  • 260
1

If you are dealing only with 1 byte chars(ASCII) then its Endian safe else its not.

the following link may be helpful.

Encode/Decode std::string to UTF-16

Community
  • 1
  • 1
Murugan P
  • 11
  • 5
0

Completing the answer of R Sahu, the problem could be the nodeMessage and how it manages the mac (I suppose that it refers to a mac address).