It's because
strtol was an old C function written far before C++ strings were invented. Although C++ strings have overloaded functions to make transitions from the older-style char strings to C++ strings and vice-versa, this problem can't be as transparently solved when passing a C++ string to a function that is expecting a char string. To remedy this, C++ strings include a nifty member function called c_str() that can quickly return the char string equivalent. Thus, you could code it like this:
temp = strtol(line.c_str(), &numEnd, 2);
Better yet, use the C++ streams, the modern equivalent of a lot of the old C string functions, rather than mixing C and C++.
Hope this helps
Reputation Points: 2240
Solved Threads: 338
Vampirical Lurker
Offline 5,055 posts
since Apr 2006