인프런 커뮤니티 질문&답변
코드를 똑같이 입력했는데
해결된 질문
작성
·
144
0
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS
void display(char cr, int lines, int width);
int main()
{
char c;
int rows, cols;
while (1)
{
scanf_s("%c %d %d", &c, &rows, &cols);
while (getchar()!='\n') continue;
display(c, rows, cols);
if (c == 'n')
break;
}
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');
}
}
사진 첨부와 같이 A 3 5 이런식으로 입력하고 엔터를 눌러도 행렬이 나오지 않습니다. 왜 이럴까요
답변 1
1
안녕하세요?
1. scanf_s 함수를 쓰셔서 그래요.
scanf_s함수 사용법은
11.4 문자열을 입력받는 다양한 방법들
에서 다뤄집니다
구글 검색하셔서 사용법을 알아낼 수도 있습니다.
2. #define _CRT_SECURE_NO_WARNINGS를 맨 윗줄로 옮겨보세요.
감사합니다.





