读文件的代码你自己写,我写死字符串测试OK
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#define MAX_ARRAY_SIZE 100
int main() {
int i, j, count = 0;
int array[MAX_ARRAY_SIZE] = {0};
char number[12] = {0};
char text[] = "(,11,32,156,1,)";
for (i = 0; i < strlen(text); i++) {
if (isdigit(text[i])) {
memset(number, 0, sizeof(number));
j = i;
while (isdigit(text[j])) {
j ++;
}
memcpy(number, &text[i], j - i);
i = j;
array[count++] = atoi(number);
}
}
printf("arrays = ");
for (i = 0; i < count; i++) {
printf("%d ", array[i]);
}
return 0;
}