Why command center is creating huge gap when I try to enter char ? Aim of program is to enter side length of square and fill it with entered character. Thank you !
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void sides(void);
int main(void) {
sides();
return 0;
}
void sides(void) {
int input;
char inputChar;
printf("Enter sides of parking lot: ");
scanf_s("%d", &input);
printf("Enter desired character: ");
scanf_s("%c", &inputChar, 1);
int x, y;
while (input != -1) {
for (y = 0; y < input; y++) {
for (x = 0; x < input; x++) {
printf("%c",inputChar);
}
printf("\n");
}
printf("Enter sides of parking lot: ");
scanf_s("%d", &input);
printf("Enter desired character: \n");
scanf_s("%c", &inputChar, 1);
}
}
I expected
Enter sides of parking lot: 5
Enter desired character: *
*****
*****
*****
*****
*****
What I get is following with not intentional gap
Enter sides of parking lot: 5
Enter desired character:
Enter sides of parking lot: *
Enter desired character:
*****
*****
*****
*****
*****
Enter sides of parking lot: