First of all, I have a function where I have signs stored in unsigned char* type. For example for Abcdef!? it is [65 0] [98 0] [99 0] [100 0] [101 0] [102 0] [33 0] [63 0] 2 bytes per sign in Unicode.
When I use for(unsigned char i=0; i<17; i++) printf("%c", pointer[i]); everything is ok, it shows Abcdef!?. But when I use printf("%s" pointer); it gives me only A and nothing else. Could you tell me why?
Because printf("%s", pointer) literally means: Print every char starting at the one stored at pointer until '\0' is encountered.
There's a '\0' immediately after 'A', so only the first character is printed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With