Thread: In desparate need of help!!!

  1. #1
    Unregistered
    Guest

    In desparate need of help!!!

    I've pasted my code below to let everyone see.
    I can't get it to run yet, there's an error that I not sure what it is...
    If you can help pleaseeeeeeee do
    Many thanks...



    #include <iostream.h>
    #include <string.h>
    #define max 10

    class List_class
    {
    private:
    char num[max][15];
    int size;

    public:
    List_class();
    void to_screen ();
    int List_class::full ();
    void insert (char new_num[15]);
    };

    //-----------------------------------------------------------------------

    void main(void)
    {
    List_class num_list;
    char want[15];

    cout << "Enter the first number in the list or -1 to finish: ";
    cin >> want;
    while (!num_list.full() && want != "E")
    {
    num_list.insert (want);
    cout << "\n\n";
    num_list.to_screen ();
    if (!num_list.full())
    {
    cout << "\n\nEnter a positive number for the list or -1 to finish: ";
    cin >> want;
    }
    else
    {
    cout << "\n\nList is now full.";
    } // if
    } // while
    } // main

    //-----------------------------------------------------------------------

    List_class::List_class()
    {
    int i;

    for (i = 0; i < 10; i = i + 1)
    {
    num[i] = "ZZZ";
    } // for
    size = 0;
    } // Constructor

    //-----------------------------------------------------------------------

    void List_class::to_screen ()
    // displays the list to the screen
    {
    int a;

    cout << "This is the list: " << endl << endl;
    for (a = 0; a < size; a = a + 1)
    {
    cout << num[a] << " ";
    } // for
    } // show_list

    //-----------------------------------------------------------------------

    int List_class::full ()
    // returns TRUE if the list is full
    {
    return (size == 10);
    } // show_list

    //-----------------------------------------------------------------------

    void List_class::insert (char new_num[])
    // adds the new element to the appropriate location in the list.
    {
    int old, spot = 0, spot_found = 0;

    while (!spot_found && spot < size)
    {
    if (strcmp(new_num, num[spot]) < 0 || strcmp(new_num, num[spot]) == 0)
    {
    spot_found = 1;
    }
    else
    {
    spot = spot + 1;
    } // if
    } // while
    for (old = size; old > spot; old--)
    {
    strcpy(num[old], num[old - 1]);
    } // for
    size = size + 1;
    strcpy(num[spot], new_num);
    } // insert

  2. #2
    Unregistered
    Guest

    To vVv Please read :)

    Ohhhh my G@%!!!!!!
    It works!!!!!
    I can't believe, all I had to do was use the string copy. Now why didn't I think of that... I guess I'm an idiot LOL

    vVv your a G@#!!!!!!!
    I can't thank-you enough, thanks mate.

    Your a G#$!!! I've told you that already haven't I?

    Many, many, many thanks vVv

  3. #3
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    lol

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I can't believe, all I had to do was use the string copy.
    Care to guess how common that mistake is?

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code in desparate need of corrections!
    By Narclepto99 in forum C++ Programming
    Replies: 2
    Last Post: 04-14-2003, 11:29 PM
  2. deciaml place help
    By artgirloc in forum C++ Programming
    Replies: 3
    Last Post: 12-03-2002, 07:47 PM
  3. For Loop - Need desparate help!
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 11-28-2001, 02:42 PM