Atoi
Macro that converts string to integer
Declaration:
int atoi(const char *s);
Remarks:
atoi converts a string pointed to by s to int. atoi recognizes (in the following order) an optional string of tabs and spaces an optional sign a string of digits The characters must match this format: [ws] [sn] [ddd] In atoi, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are undefined).
Return Value:
On success, returns the converted value of the input string. If the string can't be converted, returns 0.
Example:
#include<stdlib.h>
#include <stdio.h>
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n);
}
Macro that converts string to integer
Declaration:
int atoi(const char *s);
Remarks:
atoi converts a string pointed to by s to int. atoi recognizes (in the following order) an optional string of tabs and spaces an optional sign a string of digits The characters must match this format: [ws] [sn] [ddd] In atoi, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are undefined).
Return Value:
On success, returns the converted value of the input string. If the string can't be converted, returns 0.
Example:
#include<stdlib.h>
#include <stdio.h>