Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //i have to rid of everything, and leave only basic, to find out, how exactly combination of getchar() and
- //scanf() works, when they share potok
- //now i can't predict, what happened if i enter
- //s k 1 2 and why
- //.....
- //i have to be able to predict exactly the way programm works, before running it
- void display(char cr, int lines, int width);
- int main(void)
- {
- int ch; /* character to be printed */
- int rows, cols; /* number of rows and columns */
- printf("Enter a character and two integers:\n");
- while ((ch = getchar()) != EOF)//if '\n' instead of EOF, works just once!
- {
- printf("before scanf rows is %d, cols is %d\n",rows,cols);
- printf("scanf returns %d elements\n", scanf("%d %d", &rows, &cols));
- printf("after scanf rows is %d, cols is %d\n",rows, cols);
- //scanf("%d %d", &rows, &cols);
- display(ch, rows, cols);
- printf("Enter another character and two integers;\n");
- printf("Enter a newline to quit.\n");
- }
- printf("Bye.\n");
- return 0;
- }
- void display(char cr, int lines, int width)
- {
- int row, col;
- for (row = 1; row <= lines; row++)
- {
- for (col = 1; col <= width; col++)
- putchar(cr);
- putchar('\n'); /* end line and start a new one */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement