This is a piece of code from some book. According to book, this code must not have worked and should have given a error message saying "cannot convert parameter 1 from 'const char[15]' to 'char*'"
but this code is running on turbo C giving just a error message of const to * conversion ????? please tell me whether this code is right ??????
and also try to explain that what does the keyword const means when it is used with enum. What actually becomes constant when we use const with the union variable ??????
Thanks in advance :)
#include<stdio.h>
#include<conio.h>
#include<string.h>
int fun (const union employee *e);
union employee
{
char name[15];
int age;
float salary;
};
const union employee e1;
void main()
{
clrscr();
strcpy(&e1.name,"A");
fun(&e1);
printf("%s %d %f",e1.name,e1.age,e1.salary);
getch();
}
int fun(const union employee *e)
{
strcpy((*e).name,"B");
return 0;
}