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];
char address[101];
int age;
float salary;
};
/*Now for functions prototype*/
struct employee read_emp_age();
struct employee read_emp();
puttingfunction();
struct employee read_emp_salary();
print_emp_asker(struct employee emp);
/*>>>>>>>>>>>>>>>>>>>*/
puttingfunction(){
fputs("Please Enter your num: ",stdout);
return 0;
}
print_emp_asker(struct employee emp)
{
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:
emp=read_emp_age();//to get the number by returned by the function read_emp
printf("%s",emp.postion);
printf(" is %d:\n",emp.postion);
break;
case 2:
emp=read_emp_salary();//to get the number by returned by the function read_emp
printf("%s",emp.postion2);
printf(" is : %f\n",emp2.postion2);
break;
case 3:
emp=read_emp_age();
fflush(stdin);
emp=read_emp_salary();
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 read_emp_age()
{
struct employee emp;
puttingfunction();
scanf("%d",&emp.age);
return emp;
}
struct employee read_emp_salary()
{
struct employee emp;
puttingfunction();
scanf("%f",&emp.salary);
return emp;
}
int main(void)
{
struct employee emp;
print_emp_asker(emp);
return 0;
}