1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <stdio.h> #include <string.h> int main() { char temp[7]; int i; memset(temp, 0, sizeof(temp)); temp[0] = '4'; temp[1] = '2'; i = atoi(temp); printf("Foo: %s\n", temp); printf("Bar: %d\n", i); return 0; }
1 2
Foo: 42 Bar: 42