Search:

Type: Posts; User: Heathtech

Search: Search took 0.01 seconds.

  1. Replies
    15
    Views
    2,109

    Whoops, that was a typo. Yes that is what I...

    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...
  2. Replies
    15
    Views
    2,109

    I don't want to post more than is necessary to...

    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...
  3. Replies
    15
    Views
    2,109

    I need that function to set the data variable to...

    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.
  4. Replies
    15
    Views
    2,109

    MK27: There is actually a lot more data within...

    MK27:
    There is actually a lot more data within the structure, not just the int*.
  5. Replies
    15
    Views
    2,109

    Okay. I'm no good at figuring out stack traces,...

    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...
  6. Replies
    15
    Views
    2,109

    Well, that's what I thought, but when I removed...

    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,...
  7. Replies
    15
    Views
    2,109

    Yes. I wrote it as a shortcut to malloc or...

    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...
  8. Replies
    15
    Views
    2,109

    Pointer Structure of Arrays?

    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*));
    ...
    }
  9. Replies
    2
    Views
    782

    Ah, yes. The (*n)[i] fixed the problem. I had...

    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!
  10. Replies
    2
    Views
    782

    Convert string literals?

    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]...
  11. Replies
    5
    Views
    1,894

    Thanks for your help everyone. I was not aware...

    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.
    ...
  12. Replies
    5
    Views
    1,894

    [C] Struct allocation crash?

    (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,...
Results 1 to 12 of 12