Hello, I'm working o a function that takes a file with binary numbers and returns the sum of those numbers. Here's where I'm now
int Sum (char *fileName)
{
char * numEnd;
long temp(0);
int result(0);
string line;
ifstream file (fileName);
if (file.is_open())
{
while (! file.eof() )
{
getline (file,line);
//Convert line to an long and sum up with the rest
temp = strtol(line, &numEnd, 2);
result = result + temp;
//Done
}
// close the stream
file.close();
}
return result;
}
and here's an error I'm getting when building it:
error C2664: 'strtol' : cannot convert parameter 1 from 'std::string' to 'const char *'
I thought strtol needed a pointer to the string, but changing line to pointer to line didn't help. Anyone can point me in a right direction?