STUDY/C++
C/C++ 입력함수 scanf()
Trip the light
2021. 11. 10. 03:42
- 지정된 형식에 따라 키보드로부터 데이터를 입력받는 함수
- scanf("형식 문자열", &변수1, &변수2, ...);
#include <iostream>
using namespace std;
int main()
{
int x;
scanf("%d", &x);
printf("x:%d\n", x);
return 0;
}
입력장치(키보드)로 10진수 하나를 입력받아 x라는 변수에 저장한다.
출력:
1 x:1 Press any key to continue