Results 1 to 3 of 3

Thread: Query with a Function in C

  1. #1
    Contributing Member
    Join Date
    May 2006
    Answers
    72

    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.


  2. #2
    Contributing Member
    Join Date
    May 2006
    Answers
    71

    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>


  3. #3
    Expert Member
    Join Date
    Mar 2012
    Answers
    208

    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
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact