Search:

Type: Posts; User: riddinon24z

Search: Search took 0.00 seconds.

  1. Replies
    38
    Views
    38,032

    Noted. Thanks. And we are clear about memory...

    Noted. Thanks. And we are clear about memory leaks being a bug. I was just so focused on sorting the nodes at the time.
  2. Replies
    38
    Views
    38,032

    Yeah I actually forgot. I was going to ask about...

    Yeah I actually forgot. I was going to ask about that because when I took it out, it still worked. So, instead I have to free line.age and line.number after every time it increments in my getData...
  3. Replies
    38
    Views
    38,032

    Alright I finally got it to work. I'm...

    Alright I finally got it to work. I'm embarrassed. It may not be the prettiest code, but I got it done. I actually took CommonTater's advice and wrote on paper before I inserted any code. That helped...
  4. Replies
    38
    Views
    38,032

    I tried that and it didn't work. Sorry, everyone....

    I tried that and it didn't work. Sorry, everyone. I'm just not cut out for this, especially during this time of the hour. Thanks for all your advice. A lot of it was more helpful than I thought it...
  5. Replies
    38
    Views
    38,032

    When you say, Do you mean putting the if...

    When you say,


    Do you mean putting the if statements in a different order? And as for the pCur, yeah it makes sense to use it to assign anything. If pList is NULL, are pList and pList-> the same...
  6. Replies
    38
    Views
    38,032

    The reason for the traverse function is that it...

    The reason for the traverse function is that it assigns the value of pCur to pPre and then assigns pCur->link to pCur if the while statement is true. My teacher recommend using this function.

    And...
  7. Replies
    38
    Views
    38,032

    Am I making this way more complicated than it...

    Am I making this way more complicated than it should be? Would it help if I initialized pPre and pCur to something else and go from there?
  8. Replies
    38
    Views
    38,032

    Thanks, but that didn't sort me out. I don't even...

    Thanks, but that didn't sort me out. I don't even understand the second half of that. Am I still not accounting for the next-to-last position?


    pPre = NULL;
    pCur = pList;

    printf("%d\n",...
  9. Replies
    38
    Views
    38,032

    I keep coming back to something like this: ...

    I keep coming back to something like this:


    pPre = NULL;
    pCur = pList;

    printf("%d\n", pNew->character.age);

    while ((pNew->character.age < pPre->character.age) && (pCur->link !=...
  10. Replies
    38
    Views
    38,032

    Sorry, I'm having trouble understanding. Do you...

    Sorry, I'm having trouble understanding. Do you mean something like this: Let's say that so far my list contains 22 33 44 55 and I am trying now to insert 40. The first part of my if statement will...
  11. Replies
    38
    Views
    38,032

    I changed it again to this: pPre = NULL; ...

    I changed it again to this:


    pPre = NULL;
    pCur = pList;

    printf("%d\n", pNew->character.age);

    while ((pNew->character.age < pPre->character.age) && (pCur->link != NULL))
    {
  12. Replies
    38
    Views
    38,032

    I changed a portion of the insertNode function....

    I changed a portion of the insertNode function. Am I not accounting for every situation?


    pPre = NULL;
    pCur = pList;

    while ((pNew->character.age < pPre->character.age) && (pCur->link !=...
  13. Replies
    38
    Views
    38,032

    If instead I tried to insert the nodes in...

    If instead I tried to insert the nodes in numerical order based on the age, which would be new->.character.age, is it illogical or incorrect for me to have my if statement the opposite of my while...
  14. Replies
    38
    Views
    38,032

    Oh I guess I kinda forgot c programming 101. So...

    Oh I guess I kinda forgot c programming 101. So that means my getData function will also be affected by your advice. I changed the type of the getData function again but this time to my structure...
  15. Replies
    38
    Views
    38,032

    Ok. Here's what I came up with. I changed the...

    Ok. Here's what I came up with. I changed the type of the getData function from bool to void. Don't know whether or not that was a good idea. I took the fgets function from getData and put it into...
  16. Replies
    38
    Views
    38,032

    I'm just thinking out loud. What I'm trying to do...

    I'm just thinking out loud. What I'm trying to do is read one line of data from the text file into a node. Then insert that node into my list and put that entire process into a loop until all lines...
  17. Replies
    38
    Views
    38,032

    I think I see what you're saying. So I should put...

    I think I see what you're saying. So I should put something like this in my insertNode function:


    The reason I'm using dynamic memory allocation is because my teacher told us to do so.
  18. Replies
    38
    Views
    38,032

    Read text file into a linked list

    I'm having trouble dealing with the multiple lines of data in my text file:



    Note: There are tabs, not spaces, before and after the numbers.

    I actually tried reading the data two ways, but...
Results 1 to 18 of 18