I want to run a simple program:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int c;
printf("Please enter a letter: ");
while ((c = getchar()) !='.')
printf("The letter is: %c", c);
return 0;
}
But when I write strings in the printf-function the Output looks like this (with "a" as input example):
Please enter a letter: a
The letter is: aBuchstabe:
And even, when I use a umlaut, for example "ü" then I get this:
Please enter a letter: �
The letter is: �The letter is: �The letter is:
I thought, I can use getchar() for Umlaute/Umlauts?! It seems like printf() cant handle it. But I don't know what to do. When I use putchar() I will get the umlaut. Or is it not possible to use umlaute/umlauts in Clang? I know, that there is a set of signs which are permitted for sourcecode in C.
What I do wrong?
When dealing with anything more than the basic English alphabet, you have to move to wide characters. There is a high chance that
ütakes more than one byte - it just does not "fit" into char.Also, check for EOF.