抱歉这个令人困惑的问题,但我想做的是将数组存储在变量中。
我想将数字存储在*value
其中,而int value: -12118433669
不是int value: 123456789
.
输出
123456789
array: '123456789' int value: -1218433669
0001234
array: '0001234' int value: -1218433669
5
array: 'abc5xyz' int value: -1218433669
array: '' int value: -1218433669
987654321
array: '987654321' int value: -1218433669
来源
#include <stdio.h>
MyFNatoi(char *numArray, int *value) {
int i;
for (i = 0; i < 10; i++) {
if (numArray[i] > 47 && numArray[i] < 58) {
printf("%c", numArray[i] - 0);
}
}
}
int main() {
char numbers[5][10] = { "123456789", "0001234", "abc5xyz", "", "987654321" };
int i, value;
for(i = 0; i < 5; i++) {
MyFNatoi(numbers[i], &value);
printf("\narray: '%s' int value: %d\n", numbers[i], value);
}
return 0;
}