Here is my program to uppercases all letter inputted from the standard input. But some output is very strange. For example, if input is "lorem ipsum" and output will be "LOREM IPSUMS?". If input is a single character such as 'm', the output will be "MZ#X?" . "S?" and "Z#X?" should not be here but they append to the output.
Why this happens?
#include <stdio.h>
#include <ctype.h>
int main(void){
char input;
char upper[100];
int count = 0;
while((input = getchar())){
if(input == '\n')
break;
if(input >= 'a' && input <= 'z')
input = toupper(input);
*(upper + count) = input;
count++;
}
printf("%s\n", upper);
return 0;
}