environment: Windows 7, 64 bit, Visual Studio 2008, C++
After finding that atoi returns 0 on error, I shifted to strol because it sets the system error value. However, if the string to be converted is not "0" then the error is always 122. Help files explaine this as: ERROR_INSUFFICIENT_BUFFER, The data area passed to a system call is too small.
I changed the return value from an int, then to a long, then to a long long with no effect.
In the above example, the string to be converted shows up in the debugger as "5508" or "16" or other such strings. Some not shown code isolates the string to be converted and puts it in t_string. The dugger shows that the conversion is correct even when GetLastError returns 122.
We need to know what a dragon is
before we study its anatomy.
(Bryan Kelly, 2010)
Code:
string t_string;
...
long long temp = strol( t_string.c_str(), NULL, 10 )
long error = GetLastError();
*return_value = (int) temp;
After finding that atoi returns 0 on error, I shifted to strol because it sets the system error value. However, if the string to be converted is not "0" then the error is always 122. Help files explaine this as: ERROR_INSUFFICIENT_BUFFER, The data area passed to a system call is too small.
I changed the return value from an int, then to a long, then to a long long with no effect.
In the above example, the string to be converted shows up in the debugger as "5508" or "16" or other such strings. Some not shown code isolates the string to be converted and puts it in t_string. The dugger shows that the conversion is correct even when GetLastError returns 122.
We need to know what a dragon is
before we study its anatomy.
(Bryan Kelly, 2010)