Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why 2nd scanf doesn't work in my program?

Tags:

scanf("%d %c",&size,&chara); works but separate scanf for character input does not work. I show these inside the code. Why is that?

void squareCustomFill(int size, char chara);

int main(void) {

int size,i,k;
char chara;

printf("Enter size of square: ");   //This works
scanf("%d %c",&size,&chara);

//printf("Enter fill character: ");      BUT WHY DOES NOT THIS WORK??
//scanf("%c",&chara);

squareCustomFill(size,chara);

return 0;

 }

void squareCustomFill(int size, char chara){

int i,k;

for (k=1;k<=size;k++){

    for(i=1;i<=size;i++)
        printf("%c",chara);
        printf("\n");

 }
}