I want to use the getline function with a char*
.
I don't want to use std::string
because I have a function that takes char*
as parameters and writes to them and I don't want to write a whole new one just for strings.
I want to use the getline function with a char*
.
I don't want to use std::string
because I have a function that takes char*
as parameters and writes to them and I don't want to write a whole new one just for strings.
Simple answer for a simple question: use the stream's member function getline
instead of the free function.
#include <fstream>
...
std::fstream my_stream;
char buffer[ 1000 ];
my_stream.getline( buffer, sizeof buffer );
you can use getline from istream
istream& getline (char* s, streamsize n );
Simple enough
char buffer[200];
cin.getline(buffer, sizeof buffer);
But there is no such thing as the string library, so your attempts not to include it are bound to be successful!