본문 바로가기

카테고리 없음

cin, cout 속도 빠르게 하기

printf, scanf 가

cin, cout보다 속도가 빠르다.

 

근데 string 클래스 같은경우

string 변수를 출력하거나 입력받을 때

printf(), scanf()로 받으면 좀 문제가 있다고 한다.

https://stackoverflow.com/questions/10865957/printf-with-stdstring

 

printf with std::string?

My understanding is that string is a member of the std namespace, so why does the following occur? #include int main() { using namespace std; string myString = "Press EN...

stackoverflow.com

그래서 cin, cout 써야한다면

 

std::ios_base::sync_with_stdio(false);

std::cin.tie(NULL);

std::cout.tie(NULL);

 

하믄 된다.

 

참고로 저거 하면

혼용해서 사용 못한다.

 

endl 보다 "\n" 이 더빠르다.

 

가능하면 printf(), scanf() 쓰자