cpp_cout - 8BitsCoding/RobotMentor GitHub Wiki
์๋์ ๊ฐ์ ์ถ๋ ฅ์ด ๊ฐ๋ฅ!
int i = 1; double d = 2.0; float f = 3.0; long l = 4; char c = 'f'; char string[] = "string"; cout << i << endl << d << endl << f << endl << l << endl << c << endl << string << endl;๊ฒฐ๊ณผ : 1 2 3 4 f string
// C
int num = 10;
printf("%~~) // ํ๊ธฐ๊ฐ ์ด๋ ต๋ค.
// C++
int num = 10;
cout << showbase << hex << num << endl;
// showbase : ๋ค์ ์ง์๋ฅผ ํํ
// hex : 16์ง์
cout << showpos << number; // +123 -> pos๋ positive์ ์ฝ์
cout << noshowpos << number; // 123
cout << dec << number; // 10์ง
cout << hex << number; // 16์ง
cout << oct << number; // 8์ง
cout << uppercase << hex << number; // ๋๋ฌธ์๋ก
cout << nouppercase << hex << number;
cout << showbase << hex << number; // showbase : ๋ช์ง๋ฒ์ธ์ง ํํํด ๋ฌ๋ผ -> 0x7b
cout << noshowbase << hex << number;
cout << setw(6) << Left << number; // 6๊ธ์ ๋ค์ด๊ฐ์ ์๊ฒ ์ธํ
ํ ์ผ์ชฝ์ ๋ ฌ
cout << setw(6) << internal << number; // ๋ถํธ๋ ์ผ์ชฝ ์ซ์๋ ์ค๋ฅธ์ชฝ ์ ๋ ฌ
cout << setw(6) << right << numer;
cout << noshowpoint << decimal1 << " " << decimal2; // 100 100.12 ์์์ ์๋๊ฐ ์๋ค๋ฉด, ๋ณด์ฌ์ฃผ์ง๋ง๋ผ
cout << showpoint << decial1 << " " << decimal2; // ๋ฌด์กฐ๊ฑด ์์์ ํํ
cout << fixed << number; // 123.45678
cout << scientific << number; // 1.234567E+02
cout << boolalpha << bReady; // bReady๊ฐ true๋ผ๋ฉด true์ถ๋ ฅ
cout << noboolalpha << bRead; // 1
์ฌ๊ธฐ์๋ถํฐ๋ #include <iomaip>
์ ํด์ผ์ง ์ฌ์ฉ๊ฐ๋ฅ
cout << setw(5) << number;
cout << setfill('*') << setw(5) << number; // **123 -> ๋น๊ณต๊ฐ์ ์ฑ์ด๋ค.
cout << setprecision(7) << number; // 123.4568 -> ์์์ ์ ๋ช์๋ฆฌ๊น์ง ํํํด ์ค์ง ๊ฒฐ์ ํ๋ค.