Thread: Urgent!! I/O problem with linked list

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    46

    Urgent!! I/O problem with linked list

    I attached the code because it's too long to post and I can't figure out what's wrong with what

    basically I'm writing a program that inputs polynomials then lets you add and subtract them (format is like this: 3x3+2x2+1x1+3). I have two problems:

    1) my sort function isn't working at all. I've never used sorting with linked lists so I think it's a logical error. but I can't figure out how to fix it

    2) whenever I try to output any polynomial I've inputted it outputs a random number at the end, but only if the last term in the polynomial isn't a constant

    please check out the code I attached. mostly you need to look at the input function I think, but I'm not sure. I didn't add the definition for the + operator overload because it's very long and I don't use it in my main yet

  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    Just trying to fix one thing at a time, I noticed this in your bubble sort function:
    Code:
    if (temp->exp > largest)
    I think you should *dereferrence the temp->exp pointer in order to make an effective boolean comparison to 'largest'.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Linked List Problem
    By Syneris in forum C++ Programming
    Replies: 4
    Last Post: 01-07-2006, 12:03 AM
  3. doubly linked list problem
    By YevGenius in forum C Programming
    Replies: 4
    Last Post: 05-02-2004, 08:54 PM
  4. Linked List
    By jpipitone in forum C Programming
    Replies: 4
    Last Post: 03-30-2003, 09:27 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM