728x90
๋ณธ ํฌ์คํธ๋ ์๋ฌธ ํฌ์คํ ์ ์์ด ์ค๋ช ์ ๋ง๋ถ์ธ ๊ธ์ ๋๋ค.
์ถ๋ ฅ๋๋ ์๋ฃ์ ์์์ ์ค์ ํ๊ธฐ ์ํด์ ์คํธ๋ฆผ ์กฐ์๊ธฐ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
์คํธ๋ฆผ ์กฐ์ง๊ธฐ๋ iomanip.h ํค๋ ํ์ผ์ ์ ์๋์ด ์์ต๋๋ค.
To set the format of the output data, we use a stream manipulator.
The stream manipulator is defined in the iomanip.h header file.
dec | 10์ง์ (decimal) |
hex | 16์ง์ (hexadecimal) |
oct | 8์ง์ (octal) |
endl | "\n"์ ์ฝ์ ํ๊ณ ์คํธ๋ฆผ ๋ด์ฉ ์ญ์ (Insert "\n" and delete stream contents) |
ends | ๋ฌธ์์ด์ ๋ ๋ฌธ์ ์ค์ (Setting a null character in a string.) |
setfill(int c) | c๋ก ์ฑ์ฐ๊ธฐ ๋ฌธ์ ์ค์ (Setting the fill character in C.) |
setprecision(int n) | n์ผ๋ก ๋ถ๋ ์์์ ์ ์ ํจ ์๋ฆฌ ์ค์ (Setting the precision of floating-point numbers to 'n'.) |
setw(int n) | n์ผ๋ก ํ๋์ ํญ ์ค์ (Setting the field width to 'n'.) |
setiosflags(long f) | ํ์ ํ๋๊ทธ ์ค์ (Setting format flags.) |
resetiosflags(long f) | ํ์ ํ๋๊ทธ ์ญ์ (Clearing format flags.) |
setiosflags()์ resetiosflags()๋ฅผ ์ํ ํ์ ํ๋๊ทธ ๊ฐ
ios::left | setx() ํญ์์ ์ถ๋ ฅ์ ์ข์ธก์ผ๋ก ์ ๋ (Set the output to be left-aligned within the width using setx().) |
ios::right | setw() ํญ์์ ์ถ๋ ฅ์ ์ฐ์ธก์ผ๋ก ์ ๋ (Align the output to the right within the width using setw().) |
ios::scientific | ๋ถ๋ ์์์ ํ๊ธฐ, ์ง์ํํ๋ก(1.2345E2) (Floating-point notation in exponential form (1.2345E2).) |
ios::fixed | ๋ถ๋ ์์์ ํ๊ธฐ, ์์ํํ๋ก(123.45) (Floating-point notation in decimal form (123.45).) |
ios::dec | 10์ง์๋ก ์์น๋ฅผ ํ๊ธฐ (Represent the numerical value in decimal.) |
ios::hex | 16์ง์๋ก ์์น๋ฅผ ํ๊ธฐ (Represent the numerical value in hexadecimal.) |
ios::oct | 8์ง์๋ก ์์น๋ฅผ ํ๊ธฐ (Represent the numerical value in octal.) |
ios::uppercase | 16์ง์์ ๊ณผํ์ฉ ํ๊ธฐ์ ๋ฌธ์๋ฅผ ๋๋ฌธ์ ํ์์ผ๋ก ํ๊ธฐ (Show the base using uppercase letters for hexadecimal and scientific notation) |
ios::showbase | ์์น ๋ฒ ์ด์ค ์ ๋ ๋ฌธ์๋ฅผ ์ถ๋ ฅ (Output the numerical base prefix characters.) |
ios::showpos | ์์๋ฅผ ์ถ๋ ฅํ ๋ +๋ถํธ๋ฅผ ์ถ๋ ฅ (Print the positive sign when outputting positive numbers.) |
ios::showpoint | ์ ํ๋๋ฅผ ์ํด ํ์ํ๋ฉด ๋์ 0๋ค์ ์ถ๋ ฅ (Print trailing zeros for precision if necessary.) |