Converting String to Long in C
Here, we will see how to build a C Program For String to Long Conversion using strtol() function.
long int strtol(char *string, char **ptr, int base)
- The first argument is given as a string
- The second argument is a reference to an object of type char*
- The third argument denotes the base in which the number is represented. To know more about visit strtol() function.
Note: We don’t have to use long int in the case of strtoul() because the range of unsigned long is greater than long on the positive front.
[long : -2147483648 to 2147483647 and unsigned long : 0 to 4294967295]
strtoul(char *string, char **ptr, int base) // no long int need in strtoul()
Number is 1234567890
Integer part is 100 String part is GeeksforGeeks
Method: Using atol() function
l = 349639
Method: Using ltoa()
string is 1234
Method: Without Inbuilt Function
Number is 123456789
My Personal Notes arrow_drop_up
Please Login to comment...