Error, '=': left operand must b |-value

This is a discussion on Error, '=': left operand must b |-value within the C++ Programming forums, part of the General Programming Boards category; I need to know what's wrong with the employee1.name & employee2.name in this program code, I receive the following error: ...

  1. #1
    Amy amirahasanen1's Avatar
    Join Date
    Jul 2003
    Posts
    49

    Error, '=': left operand must b |-value

    I need to know what's wrong with the employee1.name & employee2.name in this program code, I receive the following error:

    '=': left operand must b |-value

    Code:
    #include <iostream.h>
    #include <string.h>
    struct database
    {
      char name[6];
      int id;
      int age;
      float salary;
    };
    int main()
    {
      //the database
      database employee1;
      employee1.name="Amira";
      employee1.id=1;
      employee1.age=16;
      employee1.salary=12000;
    
      database employee2;
      employee2.name="Erica";
      employee2.id=2;
      employee2.age=15;
      employee2.salary=10005;
    
      //the program code
      cout<<"Please write the employee ID to know more information about: ";
      int input;
      cin>>input;
      cout<<endl<<" "<<endl;
    
      switch (input)	
      {	   
       case 1: cout<<"Name: "<<employee1.name<<endl;
    	cout<<"ID: "<<employee1.id<<endl;
    	cout<<"Age: "<<employee1.age<<endl;
    	cout<<"Salary: "<<employee1.salary<<endl;
    	   break;
       case 2: cout<<"Name: "<<employee2.name<<endl;
    	cout<<"ID: "<<employee2.id<<endl;
    	cout<<"Age: "<<employee2.age<<endl;
    	cout<<"Salary: "<<employee2.salary<<endl;
            break;
        default: cout<<"Error, bad input"<<endl<<" "<<endl;
      }
     
      //the next code is for ending the program
      cout<<" "<<endl;
      cout<<"Press T letter then Enter to terminate the program"<<endl;
      char string;
      cin>>string;
      if(string=='t')
      {
    	  return 0;
      }
      else
      {
    	  cout<<"Error, bad input.";
    	  main();
      }
      return 0;
    }
    Last edited by amirahasanen1; 08-07-2003 at 07:02 AM.
    It ain't illegal until you get caught..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL, loading BMP Textures?
    By Zeusbwr in forum Game Programming
    Replies: 12
    Last Post: 12-09-2004, 04:16 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM

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