I am a starter and this is my original program:
#include <stdio.h>
int main(void){
char c;
int n,m,i,j,w;
scanf("%c %d %d",&c,&m,&n);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%c",c);
}
printf("\n");
}
return 0;
}
I want to repeat the input, so I add a while
loop:
#include <stdio.h>
int main(void){
char c,d;
int n,m,i,j,w;
while(1){
scanf("%c %d %d",&c,&m,&n);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
printf("%c",c);
}
printf("\n");
}
}
return 0;
}
When I run the program, the first input and output is normal, but it has an empty region between the second input and second output and so on, and I don't know why, and how can I correct my program?