C++
[C++] 출력(Output)
imagineer_jinny
2022. 1. 4. 01:19
본 내용은 POCU COMP3200: C++ 언매니지드 프로그래밍 강의를 토대로 작성하였습니다.
1. 네임스페이스 (namespace)
- Java의 패키지나 C#의 네임스페이스와 비슷
- 이런 것들과의 이름 충돌을 피하기 위해
- ex) 함수, 클래스, 기타 등등
namespace hello
{
void PrintHelloWorld();
}
// 1. Namespace Example
hello::SayHelloExample();
hi::SayHelloExample();
2. using 지시문
- Java의 import나 C#의 using과 비슷
- 타이핑의 양을 줄이는 방법일 뿐임
- ex) using namespace std;
3. << 연산자(operator)
- +나 -와 같은 연산자로 프로그래머가 연산자의 동작을 바꿀 수 있음
4. 출력형식 지정(Output Formatting)
- Manipulator(조정자) - 읽기 쉽다!
- ex) showbase 어떤 진수로? hex 16진수로 보여줘. number은 10의 16진수 형태로 나옴
int number =10;
cout<<showbase<<hex<<number<<endl;
- 조정자 종류
setw는 컬럼수 설정해주는 것.
showpoint/noshowpoint 소수점 이하를 보여준다/ 안보여줄수있으면 보여주지 말아라
#include <iomanip> 안에 있는 조정자
setprecision: 유효한 숫자 얼마나 보여줄것인지