There is a task, to draw a square through a function, and at the same time to give it a side and from what symbols it will be built. I did everything I can not understand the reason why it does not work, why after the introduction of the party, the program immediately ends. I do from Win 7 x64, DevC ++.
#include <stdio.h> #include <stdlib.h> void even(int side, char symbol); main() { int side = 0; char symbol; printf("Vvedite storony - "); scanf("%d", &side); printf("Vvedite symbol - "); scanf("%c", &symbol); even(side, symbol); system("PAUSE"); } void even(int i, char symbol) { for (int j = 1; j <= i; j++) { for (int m = 1; m <= i; m++) { printf("%c", symbol); } printf("\n"); } return; }
upd. the problem is in
printf("Vvedite symbol - "); scanf("%c", &symbol);
main
function. 2. And what happens if you do not read the values of variables from the console, but specify them directly in the code? 3. Your question title gives sensationalism. - VladDskipnl()
. Naturally, the "forward" this macro does not look. If someone suddenly wants, then you can #define skipnleof () ({char b [1024], * res = NULL; fgets (b, 1024, stdin); \ int c = getchar (); if (c! = EOF) {ungetc (c, stdin); res = b;} \ res;}) andoops
will not appear. Of course 1) formatting in comments is difficult; 2) such peering ahead for unbuffered IMHO will not work. - avp