c++ - What happens when we cast char to a number greater than 256? -


i created program create 256 unique symbols, , works fine. works writing binary (char) cast of 1-256. if decide print (char)257 file, file still has 256 unique symbols. when cout (char)257, don't see on screen. empty character or point something?

also if ascii 128 letters, call term 256 characters? utf-8?

when cast 257 char, value truncated 1.

assuming sizeof(int) 4 in platform, 257 represented 0x00000101 in hex. when truncate char performing cast, 0x01, equal 1. ascii character represented 1 not printable character. hence, don't see output when use:

std::cout << (char)257; 

if use:

char c = (char)257; std::cout << (int)c << std::endl; 

you should see 1 output.

what call term 256 characters?

i believe talking extended ascii characters.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -