#include <iostream>
#include <sstream>
int main()
{
// Prepare fake stringstream
std::stringstream fake_cin;
fake_cin << "Hi";
// Backup and change std::cin's streambuffer
std::streambuf *backup = std::cin.rdbuf(); // back up cin's streambuf
std::streambuf *psbuf = fake_cin.rdbuf(); // get file's streambuf
std::cin.rdbuf(psbuf); // assign streambuf to cin
// Read something, will come from out stringstream
std::string input;
std::cin >> input;
// Verify that we actually read the right text
std::cout << input << std::endl;
// Restore old situation
std::cin.rdbuf(backup); // restore cin's original streambuf
}
참고해보세요.
- cin 의 rdbuf() 로. stringstream 에 값을 전달 하고 출력 : 성공
- cin 입력 안되고 넘어감.
http://goorm.io
[C++] 입력버퍼에서 데이터를 넣어놓는 함수 있나요?
https://www.codentalks.com/t/topic/842
setvbuf(3) - Linux man page
https://linux.die.net/man/3/setvbuf
std::cin
http://www.cplusplus.com/reference/iostream/cin/
C++ ignore 입력 버퍼 비우기
http://blog.naver.com/PostView.nhn?blogId=lyw94k&logNo=220859905348
STRING(3) Linux Programmer's Manual STRING(3)
http://man7.org/linux/man-pages/man3/string.3.html
std::string
http://www.cplusplus.com/reference/string/string/
std::string::max_size
http://www.cplusplus.com/reference/string/string/max_size/
std::string::resize
http://www.cplusplus.com/reference/string/string/resize/
Reading getline from cin into a stringstream (C++)
https://stackoverflow.com/questions/35974402/reading-getline-from-cin-into-a-stringstream-c
cin >> stringstream?
https://www.daniweb.com/programming/software-development/threads/456327/cin-stringstream
sstream << cin블라블라 에서 막혀서 질문드립니다.
https://www.codentalks.com/t/topic/45/22
cin to stringstream
https://bytes.com/topic/c/answers/132443-cin-stringstream
std::stringstream
http://www.cplusplus.com/reference/sstream/stringstream/
stringstream
http://www.cplusplus.com/forum/beginner/3952/
How to temporarily redirect std::cin from a std::stringstream
https://www.smork.info/blog/2010/01/26/entry100126-131539.html
C++ Notes: String stream example
http://www.fredosaurus.com/notes-cpp/strings/stringstream-example.html
stringstream in C++ and its applications
https://www.geeksforgeeks.org/stringstream-c-applications/
C++ Stringstreams
https://latedev.wordpress.com/2011/11/16/c-stringstreams/
cin and cout are different
http://www.cplusplus.com/forum/beginner/14200/
Basic Input/Output
http://www.cplusplus.com/doc/tutorial/basic_io/
cin >> stringstream?
https://www.daniweb.com/programming/software-development/threads/456327/cin-stringstream
Mystr << cin.rdbuf();
c++ execute function any time a stream is written to
https://stackoverflow.com/questions/12826751/c-execute-function-any-time-a-stream-is-written-to
std::basic_stringstream
https://en.cppreference.com/w/cpp/io/basic_stringstream
std::basic_ios::rdbuf
https://en.cppreference.com/w/cpp/io/basic_ios/rdbuf
std::ios::rdbuf
http://www.cplusplus.com/reference/ios/ios/rdbuf/
How to read until EOF from cin in C++
https://stackoverflow.com/questions/201992/how-to-read-until-eof-from-cin-in-c
The C++ Standard Library: A Tutorial and Reference
https://books.google.co.kr/books?id=9DEJKhasp7gC&pg=PA847&lpg=PA847&dq=cin.rdbuf+EOF&source=bl&ots=_bZdP4EwWB&sig=ccJZOsY2q-mNTUOQCLTSJvWdh_E&hl=ko&sa=X&ved=2ahUKEwj8jbK-mLLdAhXB4IMKHQeSBp8Q6AEwA3oECBEQAQ#v=onepage&q=cin.rdbuf%20EOF&f=false
get int from stdin
http://rextester.com/XEDB66063
Going Beyond End of File:
More Filtering Streambufs
http://gabisoft.free.fr/articles/fltrsbf2.html
----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.
매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.
각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com
그런 문제가 발생할 일반적인 이유는 없습니다.
그런 문제가 발생할 일반적인 이유는 없습니다.
코드에 뭔가 문제가 있는 모양인데, 직접 살펴보지 않고는 알 수가 없겠네요.
답변 감사합니다!ㅎㅎ
setvbuf (stdin, NULL, _IOFBF, 16384); 함수 이용해서 버퍼 사이즈를 늘렸습니다! 답변 감사합니다!
댓글 달기