Printf width modifier for special characters

I have a problem with printf width modifier in C

Example:

char a[] = "o", b[] = "l";

printf("%-3s %s", a, b);

console output gives me 3 spaces between lines, but when I change "o" to "-", the console shows 2 spaces between them. Every time I use the symbol "ł", "ó", "ś" in a string, the width modifier is reduced by 1 character, why is this happening?

OS X 10.11 (El Captain)

+4
source share
1 answer

The "special" characters that you display need more bytes ( char) to represent in a string. Invalid arbitrary limit 3, raise it to a suitable value.

, , , . .

+3

Source: https://habr.com/ru/post/1686715/


All Articles