작성
·
144
0
안녕하세요,, 제 이해가 맞는지 여쭤보고 싶어 글을 쓰게 되었습니다.. 5분 51초의 코드 입니다..
#include<stdio.h>
void display(char cr, int lines, int width);
int main()
{
char c;
int rows, cols;
printf("Input one character and two integers : \n");
while ((c = getchar()) != '\n')
{
scanf("%d %d", &rows, &cols);
while (getchar() != '\n');
display(c, rows, cols);
printf("Input another character and two integers:\n");
printf("Press Enter to quit.\n");
}
return 0;
}
여기서 scanf ("%d %d",&rows, &cols) 다음에 바로 버퍼를 비워주는 while (getchar()!='\n')가 오지 않습니까.. 근데 이러면 버퍼를 다 비워버리는데 어떻게 디스플레이 함수로 값을 넘기는거지? 고민했습니다. 그러다 깨달은게 아 , 바보같기는,, 버퍼가 비워졌어도, 이미 받은 값들을 c , rows, cols에 저장되어 있구나,,
이게 맞습니까?,,