You can use strtoX (where X is f for float, l for long, ul for unsigned long, etc.) by selecting the desired number. One of the parameters you give it is the "end pointer", which points to the first character in the string, which cannot be converted to the type of the target number.
In your case, you are apparently looking for the end pointer to be at the end of the string, indicating that all characters in the string have been converted to the target type.
Edit: Sorry, didnโt notice that you mentioned the โdoubleโ in the title (but not the question itself). In this case, you would use strtod , as advised by a few others.
Jerry Coffin
source share