스트림 IO/기타
C++
jjryu
2009. 1. 1. 00:22
사용자 정의 객체들에 대해서 동작할 수 있는 객체 지향 입출력 시스템
입출력 라이브러리 // 표준 라이브러리
C의 입출력 시스템은 객체에 대해서는 다루고 있지 않다.
/*
or
#include <iostream.h>
//#include <stream.h>
*/
#include <iostream.h>
//#include <stream.h>
*/
ios
-> istream
-> ifstream
-> ostream
-> ofstream
-> iostream
-> fstream
표준 출력 스트림 객체
cout
.<<()
wcout
.width()
이어지는 출력에 대해 딱 한 번만 적용
.fill()
.precision()
조정자
endl
dec
oct
hex
showpos
showbase
uppercase
boolalpha
left
right
showpoint // 후행 제로
fixed
scientific
표준 입력 스트림
cin
.>>()
.get() // ::getch()
.getline()
#include <fstream>
(w)ofstream
.open() // 파일이 없으면 새로 만들고 이미 존재한다면 덮어쓴다.
ofstream f("c:\\cpptest.txt");
ios_base::out
ios_base::in
ios_base::app
ios_base::ate
ios_base::trunc
ios_base::binary
.close()
.write()
.seekp()
ios_base::beg
iso_base::end
ios_base::cur
(w)ifstream
.open()
.close()
.is_open()
.read()
.gcount()
.seekg()
fstream
#include <sstream>
std::ostringstream
std::istringstream
std::istringstream
미리 정의된 스트림
표준 스트림은 장치 또는 파일들로 설정될 수 있다.
cin, win
cout, wout
cerr, werr
cout, wout
cerr, werr
포매티드 IO
fmtflags // long
ios::skipws
ios::left
ios::right
ios::oct
ios::hex
ios::dec
ios::showbase
ios::uppercase
ios::showpos
ios::showpoint
ios::left
ios::right
ios::oct
ios::hex
ios::dec
ios::showbase
ios::uppercase
ios::showpos
ios::showpoint
std::ios
.setf()
.unsetf()
.flags()
.width()
.precision()
.fill()
.unsetf()
.flags()
.width()
.precision()
.fill()
#include <iomanip>
std::setprecision()
참조 사이트:
http://winapi.co.kr/clec/cpp4/36-1-2.htm
http://winapi.co.kr/clec/cpp4/36-1-3.htm
http://winapi.co.kr/clec/cpp4/36-1-4.htm
http://winapi.co.kr/clec/cpp4/36-1-3.htm
http://winapi.co.kr/clec/cpp4/36-1-4.htm
http://blog.naver.com/boxcj?Redirect=Log&logNo=140013288358
http://blog.naver.com/boxcj?Redirect=Log&logNo=140013288582
http://blog.naver.com/boxcj?Redirect=Log&logNo=140013288582