Code: #include<stdio.h> #include<string.h> #include<conio.h> // dish structure struct dishdetails { int dishid; char dishname[25]; float dishprice; } ; // cuisine structure struct cuisinedetails { int cuisineid; char cuisinename[25]; struct dishdetails d[20]; } ; void display(struct cuisinedetails ) ; void main() { struct cuisinedetails c[4]; clrscr(); c[0].cuisineid= 1; [B][I] c[0].cuisinename = "Italian" ;[/I][/B] c[0].d[0].dishid = 1; [B][I]c[0].d[0].dishname = "Dosa";[/I][/B] c[0].d[0].dishprice = 15.50; c[0].d[1].dishid = 2; [B][I]c[0].d[1].dishname = "Idly";[/I][/B] c[0].d[1].dishprice = 25.50; c[0].d[2].dishid = 3; [B][I] c[0].d[2].dishname = "Wada"; [/I][/B] c[0].d[2].dishprice = 30.00; c[0].d[3].dishid = 4; [B][I]c[0].d[3].dishname = "Sambhar"; [/I][/B] c[0].d[3].dishprice = 45.00; display(c[0]); getch(); } void display(struct cuisinedetails a) { printf("\n%d\t%s ", a.cuisineid,a.cuisinename); printf("\n\n%d\t%s\t%f", a.d[0].dishid,a.d[0].dishname,a.d[0].dishprice); printf("\n%d\t%s\t%f", a.d[1].dishid,a.d[1].dishname,a.d[1].dishprice); printf("\n%d\t%s\t%f", a.d[2].dishid,a.d[2].dishname,a.d[2].dishprice); printf("\n%d\t%s\t%f", a.d[3].dishid,a.d[3].dishname,a.d[3].dishprice); } I am Getting errors Lvalue required for the bold lines. wher I m tring to assign a String name in an array of characters. Please help me out.
> c[0].cuisinename = "Italian" cuisinename is defined as char[25] so the assignment operator won't work here. Use strcpy(), or define cuisinename as std::string which supports the assignment operator.