Hello again,
This is still related to my previous post but a different question about the same program...
I'm having some trouble converting a string to an array of integers... such as
string = 12345
integer[0] = 5
integer[1] = 4
integer[2] = 3
integer[3] = 2
integer[4] = 1
This is the function i have currently...
I'm getting a warning from the atoi() function as follows
[Warning] cast to pointer from integer of different size
this has been driving me mad for the past week so any help will be greatly appreciated!
This is still related to my previous post but a different question about the same program...
I'm having some trouble converting a string to an array of integers... such as
string = 12345
integer[0] = 5
integer[1] = 4
integer[2] = 3
integer[3] = 2
integer[4] = 1
This is the function i have currently...
Code:
struct integer* read_integer(char* stringInt){ struct integer* intTemp; int i, j, test; intTemp = malloc(sizeof(struct integer)); //printf("%s\n", stringInt); intTemp[0].digits = malloc(strlen(stringInt) * sizeof(int)); intTemp[0].size = strlen(stringInt); j = 1; for(i=0;i<intTemp[0].size;i++){ intTemp[0].digits[i] = atoi(stringInt[intTemp[0].size - (i+1)]); printf("%d.", intTemp[0].digits[i]); } printf("\n"); return intTemp; } //this is the definition of the struct integer struct integer { int* digits; int size; };
[Warning] cast to pointer from integer of different size
this has been driving me mad for the past week so any help will be greatly appreciated!
Comment