Reputation:
I was reading some tutorial on endianness. Got the integer part. But the tutorial left of by mentioning whether endianness issues apply also for C style strings, without mentioning correct answer. Does endiannes apply to C style strings? From my understanding, No. am I correct?
e.g., if I have string "cap" stored like this
char: c a p \0
addr: 1000 1001 1002 1003
Say it is written to file. When someone from a different endiannes reads it, I think it should still be ok, isn't it?
Upvotes: 3
Views: 126
Reputation:
Endianness only applies to entities which are longer than one byte. Thus, narrow C strings which are arrays of char
should be OK.
If you have wide strings, however, of type wchar_t[]
, then you should definitely be concerned about correctly handling endianness.
Upvotes: 7