I am writing code to multiply two int arrays and in my one function i am trying to convert the char array into an int array. I have tested many parts however i can not find the problem. any help or suggestions would be great!
Code:struct integer* convert_integer(char* stringInt){ struct integer *converted = malloc(sizeof(struct integer)); int length, i, *ints; ints = (int *)malloc(10001 * sizeof(int)); length = strlen(stringInt); printf("stringInt: %s with length of %d\n", stringInt, length); converted->size = length; for(i = 0; i < length; i++) //printf("stringInt[%d]: %s\n", i, stringInt); sscanf(stringInt, "%s", ints); //ints[i] = (int)stringInt[length - i]-'0'; //error with conversion!!!! printf("ints[%d]: %d\n", i, ints[i]); converted->digits = ints; return converted; };



LinkBack URL
About LinkBacks



