1
0

showchar1.c 822 B

12345678910111213141516171819202122232425262728293031
  1. /* showchar1.c -- program with a BIG I/O problem */
  2. #include <stdio.h>
  3. void display(char cr, int lines, int width);
  4. int main(void)
  5. {
  6. int ch; /* character to be printed */
  7. int rows, cols; /* number of rows and columns */
  8. printf("Enter a character and two integers:\n");
  9. while ((ch = getchar()) != '\n')
  10. {
  11. scanf("%d %d", &rows, &cols);
  12. display(ch, rows, cols);
  13. printf("Enter another character and two integers;\n");
  14. printf("Enter a newline to quit.\n");
  15. }
  16. printf("Bye.\n");
  17. return 0;
  18. }
  19. void display(char cr, int lines, int width)
  20. {
  21. int row, col;
  22. for (row = 1; row <= lines; row++)
  23. {
  24. for (col = 1; col <= width; col++)
  25. putchar(cr);
  26. putchar('\n'); /* end line and start a new one */
  27. }
  28. }