what does this error mean

This is a discussion on what does this error mean within the C++ Programming forums, part of the General Programming Boards category; here is the code that is causing the error list_of_strings *add_to_list(list_of_strings * start, char dumb[]) { list_of_strings *tmpptr = start; ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    17

    what does this error mean

    here is the code that is causing the error

    list_of_strings *add_to_list(list_of_strings * start, char dumb[])
    {
    list_of_strings *tmpptr = start; // (1)
    start = new(list_of_strings); // (2)
    start -> data = dumb; // (3)<--ERROR HERE
    start -> next = tmpptr; // (4)
    return start;
    }

    [C++ Error] hw3start.cpp(48): E2277 Lvalue required

    bleh? i stared at it for awhile now and dont know what it means

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    put the size of dumb[xxx] then try

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It sounds like start->data is declared as an array yet you are trying to assign a string to it with the assignment operator.
    Code:
    struct test
    {
      char data[100];
    } static *start;
    
    int main ( void )
    {
      char array[] = "This is a test";
      start->data = array; 
      // Won't work, a string cannot be assigned to an array directly
      return 0;
    }
    Code:
    #include <string>
    
    struct test
    {
      char data[100];
    } static *start;
    
    int main ( void )
    {
      char array[] = "This is a test";
      strcpy ( start->data, array ); 
      // String data is being copied correctly, this will work
      return 0;
    }
    -Prelude
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    17

    Angry

    thanks, it worked. now i have to edit so it can count for occurances. YAH!

Popular pages Recent additions subscribe to a feed

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