Does any one know what this functions stands for-' and what does it do?
thanks
Does any one know what this functions stands for-' and what does it do?
thanks
atoi converts a string to an integer, put a strings pointer and it returns an int:
Declaration: int atoi(const char *s);
itoa convets an integer to a string:
Declaration:
_ char *itoa(int value, char *string, int radix);
_ char *ltoa(long value, char *string, int radix);
_ char *ultoa(unsigned long value, char *string, int radix);
Code:#include <stdlib.h> #include <string.h> int main() { int i = 22; char buf[20]; printf("itoa %d (binary) = %s\n", i, itoa(i, buf, 2)); printf("itoa %d (octal) = %s\n", i, itoa(i, buf, 8)); printf("itoa %d (decimal) = %s\n", i, itoa(i, buf, 10)); printf("itoa %d (hex) = %s\n", i, itoa(i, buf, 16)); strcpy(buf, "05"); printf("\natoi %s = %d\n", buf, atoi(buf)); return 0; }