strtol offers more error handling capability and is safer. atol is easier to use, but is impossible to properly check for errors and exhibits undefined behavior for some erroneous input. The basic difference is that you should use strtol unless your string has already been carefully validated and you're 100% certain that the conversion will succeed with atol.
strtol takes an extra parameter that can be set to what array-element it should convert.
So you could only convert the first 3 chars to a long, or 10 or the middle 5 or ... etc.
atol does not have this functionality.
 And what Narue says is also true, because she's never wrong ;)
>How can I handle the errors in case of strtol() ?
strtol sets errno, it returns suitable values on error, and one of the parameters is a pointer that marks where the conversion stopped. You can mix and match these three error handling schemes to write a bullet-proof conversion.
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...