Difference: cin.getline () and getline (cin, st)

Which one is better and preferable? I really find the reading API incomprehensible.

+6
source share
1 answer

The member version is read in char* , the free version is read in std::string . Therefore, prefer the free version! Use it like this:

 std::istream & ins = /* ... */; std::string line; while (std::getline(ins, line)) { // process line } 
+8
source

Source: https://habr.com/ru/post/896094/


All Articles