간단한 scanf문이 작동 되자 않습니다
초롱
2023.04.01
질문 제목 : 코드가 작동이 되자 않아요 코드에서 scanf(%c,&op) 에서 케릭터 하나를 받아 넘기는 문을 구현하는데
숫자일경우에는 상관없는데 문자일 경우 거기서 멈쳐버립니다. 컴파일에는 에러가 없어서
어디가 잘못됬는지 모르겠네요.
질문 내용 : #include stdio.h
#include stdlib.h
int main() {
int oparr[32] = {0,};
int opcnt, opres, i, tmp;
char op;
printf(operand count: );
scanf_s(%d, &opcnt);
for (i = 0; i opcnt; i++) {
printf(operand %d: , i+1);
scanf_s(%d, &tmp);
oparr[i+1] = tmp;
}
printf(operator: );
scanf_s(%c, &op);/*코드실행시 이부분이하 실행이 되지 않씁니다 */
for (i = 0; i opcnt+1; i++) {
printf(%d\n, oparr[i]);
}
return 0;
}