Are C++ strings and streams buffer overflow safe?
问题 If I use std::cin, std::cout and std::string, is there any possibility that someone will exploit the buffer overflow? I ask this because I still see a lot of people that still use null-terminated strings instead of standard containers in C++. 回答1: It depends. Of course, when you use C-style code/API's, there is no difference . But using STL or C++ idioms doesn't guarantee that you're safe. C++ gives you the choice, always. Contrast these two near-identical twins: int n; std::cin >> n; std: