Search:

Type: Posts; User: lionheart

Search: Search took 0.01 seconds.

  1. Replies
    18
    Views
    18,288

    Oh, now I see. So if I free that arr, it's enough...

    Oh, now I see. So if I free that arr, it's enough "freeing"... No one but you gave me the exact explanation.

    I mean:
    outA[i] = &arr[i]

    That's all I needed to know...

    Many thanks...
  2. Replies
    18
    Views
    18,288

    Mats, can you take a look at the code on the...

    Mats, can you take a look at the code on the first page and explain to me why shouldn't I free all of the pointers in the array of pointers that point to the original array?... (I can't believe the...
  3. Replies
    18
    Views
    18,288

    Thanks for the info, Mats, but this is really...

    Thanks for the info, Mats, but this is really over my league. All I know is that someone asked me to cast just like that, and I'm doing it.
    I'm studying for my BSc now, and I know about the C++ way...
  4. Replies
    18
    Views
    18,288

    Now I get it, if I free the original array then...

    Now I get it, if I free the original array then all of the pointers that point to values in it are free too.
    Thanks, rasta_freak and thanks to this forum, I knew I could count on you...
  5. Replies
    18
    Views
    18,288

    But a1 is an array of pointers, so why shouldn't...

    But a1 is an array of pointers, so why shouldn't I free all of a1's pointers?

    There's logic in freeing all of the pointers that point to values in arr...

    (And about the casting, it is a matter...
  6. Replies
    18
    Views
    18,288

    MergeSort with an array of pointers

    I think the problem is in mergeSort() or pointerSort() functions.

    This is their code (new fix), but still freeing of memory does not working.


    int** pointerSort(int* arr, int size){
    int**...
  7. Replies
    18
    Views
    18,288

    freeArray(a1, ARRAY_SIZE); free((void*)arr); ...

    freeArray(a1, ARRAY_SIZE);
    free((void*)arr);

    'cause a1 and arr are not equal. I am freeing a1, and then arr.

    I think also that I took care of everything in this code, including indentation.
  8. Replies
    18
    Views
    18,288

    I think that I need to use malloc in...

    I think that I need to use malloc in pointerSort() in order to allocate one pointer for each cell.

    Please tell me if this is the correct fix......
    that means adding this: (to pointerSort)

    ...
  9. Replies
    18
    Views
    18,288

    This is the only time... freeArray(a1,...

    This is the only time... freeArray(a1, ARRAY_SIZE);
  10. Replies
    18
    Views
    18,288

    This is my main() void main(){ int* arr;...

    This is my main()



    void main(){
    int* arr;
    int** a1;

    //initializing an array for sampling
    arr=(int*)malloc(ARRAY_SIZE*sizeof(int));
  11. Replies
    18
    Views
    18,288

    MergeSort with array of pointers

    Hello again,
    This is one of my favourite forums in the net.
    And now for the question:
    I am trying the recursive mergeSort approach, but now I'm using an array
    of pointers, in which each of them...
  12. Replies
    5
    Views
    908

    Thanks, anon and MacGyver, I fixed it and now...

    Thanks, anon and MacGyver, I fixed it and now it's working.
    It's funny how some solutions are right under our noses.
  13. Replies
    5
    Views
    908

    I have some data in the p's first cell (index 0),...

    I have some data in the p's first cell (index 0), I want to rebuild it with another cell. So I'm keeping the first cell, and adding to a temp polynom, the new data and the old one.
    Then I'm saving...
  14. Replies
    5
    Views
    908

    a Pointer problem

    By doing so, I am trying to build a polynom (as in p).
    p is Monom*, where the struct of Monom has two int fileds: coefficient and power.
    Where's the problem?
    It appears to throw on me a heap...
  15. And as I already said, I took it and am "learning...

    And as I already said, I took it and am "learning something from it"...

    Nice to know that there are good people out there after all... for:
    "There's the respect that's makes calamity of so long...
  16. That's exactly what I meant... I will use it in...

    That's exactly what I meant...
    I will use it in the bigger project, but not yet (since the current request is using a "void" syntax
    and 2 pointers as parameters).
    I'm guessing that our supervisor...
  17. Thanks... Will be used probably in 3-4 months......

    Thanks... Will be used probably in 3-4 months... and I mean many thanks.

    As for my understanding of this function, it does way more than my currnent needs and I need to "downsize" purposes. I know...
  18. I'm implementing the function and not the void...

    I'm implementing the function and not the void main() part,
    The void main() part is being used only for output sampling...

    I'm using c++ syntax, but in a "c" kind of way... (and don't ask why, I...
  19. The correction of the checkup is: if...

    The correction of the checkup is:


    if (t==NULL && s!=NULL)
    {
    delete s;
    exit(1);
    }
    else if (t!=NULL && s==NULL)
    {
  20. By this:"the size of 's' cannot be over the...

    By this:"the size of 's' cannot be over the physical size of 't'..."
    I meant the size of 's + t' cannot go over the physical size of 't'... (sorry again)...

    And I used this thread since it is "c...
  21. But I'm using C (and don't even ask why...), and...

    But I'm using C (and don't even ask why...), and I'm sorry that I didn't let you know of the assumption: the size of 's' cannot be over the physical size of 't'...

    ...and the problem with the...
  22. Thanks, people... Now it is working and I don't ...

    Thanks, people...
    Now it is working and I don't understand why (the idea of constant vs. cin... it's stupid)...
    here's the working version...



    void main(){
    char *t, *s;
    t=new char[200];...
  23. what is wrong here??? dynamic array of chars

    I am trying to implement the simple strcat() function by using pointers.
    It states 'Access violation writing location' error, and I don't understand why...
    I also tried to implement it by not using...
Results 1 to 23 of 23