Sorry for such a vague title.
Basically, I am trying to hack a function to suit my needs. But lately I have been working a lot on python and my c++ is bit rusty.
So earlier my function took a
int func(FILE *f)
{ .....
if (fgets(line, MM_MAX_LINE_LENGTH, f) == NULL)
return MM_PREMATURE_EOF;
if (sscanf(line, "%s %s %s %s %s", banner, mtx, crd, data_type,
storage_scheme) != 5)
return MM_PREMATURE_EOF;
}
now instead of this I am directly inputing the string data
int func(std::string *data)
{ .....
// how should I modify this if statment..I want to parse the same file
// but instead it is in form of one giant string
}
Thanks
You can use the same code, just convert the data in the
std::stringinto a C string.However, you should consider passing in a const reference, since you are probably not planning on modifying your input data: