still gettin errors

This is a discussion on still gettin errors within the C++ Programming forums, part of the General Programming Boards category; im workin on a homework assignment and am having errors, im not really sure what im doing wrong... im including ...

  1. #1
    cereal killer dP munky's Avatar
    Join Date
    Nov 2002
    Posts
    655

    still gettin errors

    im workin on a homework assignment and am having errors, im not really sure what im doing wrong... im including the files, if someone can just look over them and give me some pointers thanks!

    the errors im getting are...
    (72) : error C2106: '=' : left operand must be l-value
    (169) : error C2106: '=' : left operand must be l-value

    im pretty sure i know what these mean, but im lost on how to correct them?
    Attached Files Attached Files
    Last edited by dP munky; 03-24-2003 at 02:06 PM.
    guns dont kill people, abortion clinics kill people.

  2. #2
    cereal killer dP munky's Avatar
    Join Date
    Nov 2002
    Posts
    655
    here's the .h file
    Attached Files Attached Files
    guns dont kill people, abortion clinics kill people.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>am having errors
    At least state what the errors are. And try to post only the relevant bits, you'll get quicker answers.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    What errors???

    Fast look at your *.cpp file
    Code:
    void DestroyPhoneBook(PhoneBook **headPP)
    {
    	PhoneBook *node;
    
    	while(*headPP != NULL)
    	{	
    		delete node;
    		node->next;
    	}
    }
    If it enter the while there will be a great danger that the program will crash(your node is uninitialized).

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>conductor->data.number = Numarray;

    Can't use = for arrays. Use strcpy.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    cereal killer dP munky's Avatar
    Join Date
    Nov 2002
    Posts
    655
    >>Can't use = for arrays. Use strcpy.

    could i put it through some kind of loop? like
    Code:
    while(numarray < 10)
    {
        //assign the values
    }
    or can i not assign the values that way?
    guns dont kill people, abortion clinics kill people.

  7. #7
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Check up strcpy here. Pay special attention to Magos answer.
    Last edited by ripper079; 03-24-2003 at 02:19 PM.

  8. #8
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    could i put it through some kind of loop? like
    Code:
    while(numarray < 10)
    {
        //assign the values
    }
    No, numarray is a datatype of char(array/pointer) and 10 is a integer value. You could do something like this
    Code:
    for (int i = 0; i < 8; ++i)
    conductor->data.name[i];
    conductor->data.name[8] = '\0';
    but still I would prefer strcpy.

  9. #9
    cereal killer dP munky's Avatar
    Join Date
    Nov 2002
    Posts
    655
    cool, i only ask because im not real sure if im allowed to use other headers on this assignment, im getting closer but now im getting link errors...if you have advise to make it better let me know, but i think i'll just talk to the tutor tomorrow ::shrug::
    guns dont kill people, abortion clinics kill people.

  10. #10
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Well could give you some tips
    Code:
    int counter, i = 0;
    In BuildPhoneBook and AddPhoneEntry is NOT Good. You are (again) using uninitialized values that is very dangerous exspecially when you are using it in arrays. Also Iīm not sure about
    Code:
    int LengthPhoneBook(const PhoneBook *headP)
    {
    	sizeof(headP);
    }
    but I would guess that it should return then numbers of entries in the phonebook and not the size in bytes of the pointer.

    Why not make the phonebook as a class???

    As for the linked list itīs a little more problematic because everbody has it own versions . My advice is to make a search on the board or google and you will find some code that can give you some insight how the interal stuff works. And if you donīt want to look at some code you could write a linked list with just integers(debugging is a LOT easier) and when u got a complete/working version you could easily convert it so it fits in your phonebook. Datastructures are usually very generic.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  4. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21