Code outputs capital “D” if input is single 1 or 0 in addition to desired output

Tasked with writing a small program for an intro programming course where “#”s are output in the terminal depending on the integers input, executed when EOF character is input. It looks terrible but it works fine except when a single 1 or 0 is input, then a “D” is output immediately after desired output, and I have no idea why or how it could be possible.

I’ve tried wiggling around in the array used to store input for execution and there are no “D”s in there. There are no “D”s anywhere. It doesn’t happen with any other inputs so far.

int main() {     int n = 0;     int index = 0;     int field[2000] = {};     int length = 0;     while (1)     {         int check = scanf("%d", &n);         if (check == EOF)         {                 break;         }         field[index] = n;         index += 1;         length += 1;     }     for (int i = 0; i < length ; i++)     {         if (field[i] == 0)         {             printf(" ");         }         else         {             for(int j = 0; j < field[i]; j++)             {                 printf("#");             }         }         printf("\n");     }     return 0; } 

I expected a single “#” to be output or a space, no other characters under any circumstances.