1. ## Structure problem

I was studying today structure i understand but i was trying to make the code smaller and stuff but i get 2 error

d:\c_lessons_tutrials_made_by_me\test\1lolz.cpp(26 ) : error C2106: '=' : left operand must be l-value
d:\c_lessons_tutrials_made_by_me\test\1lolz.cpp(27 ) : error C2106: '=' : left operand must be l-value

anyway here the code
Code:
```#include <stdio.h>
struct employee
{
char name[101];
char postion[4];
char postion2[7];
int age;
float salary;
};
/*Now for functions prototype*/
puttingfunction();
/*>>>>>>>>>>>>>>>>>>>*/
puttingfunction(){
return 0;
}
{
int x;
struct employee emp2;
emp.postion="Age";
emp2.postion2="Salary";
puts("DO you want salary or age or both? for both (3) for salary(2) for age press(1)");
scanf("%d",&x);
switch(x)
{
case 1:
printf("%s",emp.postion);
printf(" is %d:\n",emp.postion);
break;
case 2:
printf("%s",emp.postion2);
printf(" is : %f\n",emp2.postion2);
break;
case 3:
fflush(stdin);
printf("%s",emp.postion);
printf(" is : %d...",emp.postion);
printf("%s",emp.postion2);
printf(" is : %f\n",emp2.postion2);
break;
for(;;){
default:
puts("ERROR");}
}
return 0;
}
{
struct employee emp;
puttingfunction();
scanf("%d",&emp.age);
return emp;
}
{
struct employee emp;
puttingfunction();
scanf("%f",&emp.salary);
return emp;
}
int main(void)
{
struct employee emp;
return 0;
}```

2. You still can't assign a value to an array, even if it's inside a struct. To copy a string, you still need to use strcpy.

3. oh i thought its possible since it return the hole structure ? so its possible only for it to return only int ?

4. This has nothing to do with returning anything. You cannot assign to an array, no matter of what kind.

Code:
```int anarray[10];
char anotherarray[20];
float morearrays[30];

anarray = 5; /* can't do this */
anotherarray = "bob"; /* or this */
morearrays = 1.5f; /* or this */```
There is nothing involving a structure in your problem, other than that your structure contains an array.

5. Originally Posted by tabstop
This has nothing to do with returning anything. You cannot assign to an array, no matter of what kind.

Code:
```int anarray[10];
char anotherarray[20];
float morearrays[30];

anarray = 5; /* can't do this */
anotherarray = "bob"; /* or this */
morearrays = 1.5f; /* or this */```
There is nothing involving a structure in your problem, other than that your structure contains an array.
thanks alot,i used strcpy to copy the name.