-
Contributing Member
Query with a Function in C
Can anyone highlight what is the use of the function strtol() in C. It would be helpful if you could give me an example for knowing the usage of the function.
-
Contributing Member
Re: Query with a Function in C
The function strtol() is used to convert string into long integer. It takes the input string and starts converting it into long integer until it reaches a position in the string which cannot be converted into long integer. The library function that must be included while using this function in <stdlib.h>
-
Expert Member
Re: Query with a Function in C
The function coverts a string to long integer.An important feature of strtol() is that it accepts data in various number bases and convert to decimal.
Prototype:
long int strtol(const char *sptr, char **endptr, int base);
If the function is success then it returns the converted floating point number as a long int value.
If there is no valid conversion then an zero value is returned.
If the value is out of range then LONG_MAX or LONG_MIN is returned.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules