I need to convert my string into int array. so i make a loop over string, and call int atoi(char *p) function from stdlib.h, but it doesn`t working on mac (some times ago i tryed it on Windows, and it workong well). simple loop:
for(p = buff; *p; p++)
printf("%d", atoi(p));
whats the problem with work of this function, u think?
The function is working perfectly fine. For instance if buff contains "123", your code will print 123233.
However it seems you want to just print the value of individual digits, in which case atoi has nothing to do with your problem. Try:
for(p = buff; *p; p++)
printf("%d", *p-'0');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With