W
William Payne
Hello, when using cin.getline() with a char array, how should I specify the
size (the second parameter of getline)?
const int buffer_size = 256;
char buffer[buffer_size];
std::cin.getline(buffer, std::streamsize(buffer_size));
or
std::cin.getline(buffer, buffer_size);
?
I know, I should use std::string and I usually do, but I still want to know
the proper way. I am writing a program that will be probably converted to C
so I ended up with char arrays instead of std::string, and the program uses
a third-party api which is based on C.
// William Payne
size (the second parameter of getline)?
const int buffer_size = 256;
char buffer[buffer_size];
std::cin.getline(buffer, std::streamsize(buffer_size));
or
std::cin.getline(buffer, buffer_size);
?
I know, I should use std::string and I usually do, but I still want to know
the proper way. I am writing a program that will be probably converted to C
so I ended up with char arrays instead of std::string, and the program uses
a third-party api which is based on C.
// William Payne