Hello, I have been looking at a tutorial on another website, and this bit of code is always used:
Sorry if thhis isnt very clear, but I don understand why there is a inside the function not outside it like this: What are the differnces between these two things?
getline (cin, //some variable)
getline has two versions: the member function of cin has a signature like this
You use this one with fixed character buffers like this
// istream& getline (char* s, streamsize n );
// istream& getline (char* s, streamsize n, char delim );
I think the version which operates on std::string came later in the C++ standard, so it's declared differently (as a non-member function)
I would prefer the second version, unless you specifically want to limit lines to a certain length
// istream& getline (istream& is, string& str, char delim);
// istream& getline (istream& is, string& str);
istream::getline - C++ Reference
getline (string) - C++ Reference
Thank you for the reply. I now understand the second version, but now im confused with the first one... Is that one usually used with C-style strings?
Most of the time char* indicates a c-style string, but to be sure you should check the reference. Look at two links above.