As the message suggests, a comma operator is used in the part ("%#x", a)
.
This means
- Evaluate the left-hand operand
"%#x"
and discard the result
- Evaluate the right-hand operand
a
and make the result of evaluation to its value
In this case "%#x"
does nothing, so you should simply remove that.
In other words, the line
b = ("%#x", a) + 32;
should be
b = a + 32;
Also here is a better code:
- Check the result of
scanf()
.
- Use
tolower()
to convert a character to lowercase.
#include<stdio.h>
#include<ctypes.h>
int main(void)
{
char a;
int b;
printf("Bitte geben Sie einen Grossbuchstaben ein: ");
if (scanf("%c", &a) != 1)
{
fputs("read error
", stderr);
return 1;
}
b = tolower((unsigned char)a);
printf("%c", b);
}
The argument of tolower
is casted to unsigned char
for making sure that the argument is in the range of unsigned char
(to avoid giving a negative number in environments where char
is signed).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…