I'm trying to understand why the following program acts in such a weird way. I declare an array of chars, and input chars into it, with a while loop and scanf. However when I input letters, or digits, it runs seemingly forever. If I input a large number, or a string, it stops. Why doesn't it exit the loop after 5 iterations?
// This program runs forever if we input single-digit numbers
#include <stdio.h>
int main()
{
char u[5] = {0,};
for (int i = 0; i<5; i++) {
scanf(" %s", &u[i]);
}
printf("%s\n", u);
}