This print statement:
printf("\nString converted to lowercase: \n\n%s\n");
Has a %s
in the format string, but you didn't pass an argument to match with it.
You're getting lucky that a 0
happens to be passed, and that your printf
implementation gracefully handles that by printing (null)
. You're in undefined behaviour territory here.
If you turn on some more warning flags, your compiler will likely warn you about this kind of problem. In a quick test here, Clang didn't even need any flags:
$ clang example.c -o example
example.c:20:51: warning: more '%' conversions than data arguments [-Wformat]
printf("\nString converted to lowercase: \n\n%s\n");
~^
1 warning generated.
and neither did GCC:
$ gcc example.c -o example
example.c: In function ‘main’:
example.c:20: warning: too few arguments for format
example.c:20: warning: too few arguments for format