Here is my code
void display(char ch, int lines, int width);
int main()
{
char c;
int rows, cols;
while (1)
{
scanf("%c %d %d", &c, &rows, &cols);
display(c, rows, cols);
if (c == '\n')
break;
}
}
void display(char ch, int lines, int width)
{
for (int i = 0; i < lines; i++)
{
for (int j = 0; j < width; j++)
printf("%c", ch);
printf('\n');
}
}
I wana like this.
if I input a 2 3
It returns
aaa
aaa
But It didn't work. SO I change like this
void display(char ch, int lines, int width)
{
for (int i = 0; i < lines; i++)
{
for (int j = 0; j < width; j++)
putchar(ch);
putchar('\n');
}
}
It works well. why that code works well?? what is difference between printf and putchar?