Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

Function Strtol ()() in C

Explore Function Strtol ()() in C with clear explanations, practical examples, and useful tips.

Table of Contents

This guide covers function strtol ()() in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.

Declaring the Function Strtol ()() in C

Below is the declaration for strtol () in C:

 long int strtol ( const char * str , char ** endptr , int base ) 

Parameters

Str - This is a string representing an integer.

Endptr - This is a reference to a allocated object of type char *, whose value is set by the function to the next character in str after the numeric value.

Base - This is the base, must be 2, 8, ., 36, or special value 0.

Returns the value

This function returns an integer that has been converted as a long int value. Otherwise, the function returns 0.

For example

The following program C illustrates the usage of the strtol () function in C:

 #include #include int main () { char str [ 30 ] = "21.32301 Hoc C tai QTM" ; char * ptr ; long ret ; ret = strtol ( str , & ptr , 10 ); printf ( "Phan gia tri so (unsigned long int) la: %ldn" , ret ); printf ( "Phan chuoi la: |%s|" , ptr ); return ( 0 ); } 

Compile and run the above C program to see the results.

According to Tutorialspoint

Previous article: Function strtod () in C

Next lesson: Function strtoul () in C

FAQ

What should I check before following these steps?

Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.

Why might the process not work?

Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.

Can I undo the changes if necessary?

That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.