strtol will convert a string to a long integer. An important feature of this Funktion is the ability to accept data in various number bases and convert to decimal. If you are just working with decimal numbers, atoi is probably an easer Funktion to use.
Library: stdlib.h
Prototype: long int strtol(const char *sptr, char **endptr, int base);
Syntax: char String[]="ff"; /* string to convert */
int Base=16; /* Base 16 */
long int Ans; /* Result */
Ans = strtol(String, NULL, Base);
The Third argument (base) can have a value of 0 or 2-32.
| Anfang | Hauptindex | Schlüsselwörter | Funktionen |