Whoops, that was a typo. Yes that is what I should have in the function (but the error still persists).
The &whatever->data is supposed to pass the address of the data, which is to hold an...
Type: Posts; User: Heathtech
Whoops, that was a typo. Yes that is what I should have in the function (but the error still persists).
The &whatever->data is supposed to pass the address of the data, which is to hold an...
I don't want to post more than is necessary to ask the question... Since there is still confusion of the purpose of the function, I will post the rest of the code:
int allocint(int** i,int j,int...
I need that function to set the data variable to the address provided by malloc. I don't think that's possible if you don't pass it as a pointer... Maybe I misunderstood your comment.
MK27:
There is actually a lot more data within the structure, not just the int*.
Okay. I'm no good at figuring out stack traces, but I will try to figure out a work around.
Just as a last question, do you think that the &pField[fields]->data is being called correctly? It...
Well, that's what I thought, but when I removed the "realloc" from the function, it still came up with the same "free()" error. I didn't bother with any other functions (which have the same task,...
Yes. I wrote it as a shortcut to malloc or realloc depending on j and k. The actual code would have been inflated if I hadn't done the shortcut. Of course I cut out most of the function because I...
I had a working code, such as the one below:
typedef struct { int* data } FIELD;
FIELD* pField;
fields;
allocint(int** i,j,k) {
*i = malloc(sizeof(int*));
...
}
Ah, yes. The (*n)[i] fixed the problem. I had mistakenly identified it as being a problem with the strtok. Thank you for clearing that up!
Say I have a function like the following:
void foo(int** n,int len,char* c) {
*n = malloc(sizeof(int)*len);
int i;
for(i=0;i<len;i++) {
if(i==0) *n[0] = atoi(strtok(c,","));
else *n[i]...
Thanks for your help everyone. I was not aware that I needed a sizeof(char*). I'll look that up later to learn why. I also added the malloc before the while loop to stop the "realloc()" error.
...
(Dev-C++ in Windows Vista / GCC in Ubuntu)
My goal is to eventually read line by line from a file that contains combined lengths of text like those joined into the "input" variable.
Currently,...