Could anyone explain why we can't assign string directly through = operator in structure concept in C programming

10/3/2019 8:52:47 AM


3 Answers

New Answer


in the latest standard only int main() is allowed


A string in C is a char array and you can't assign to arrays. Example: // struct S { char str[11]; }; struct S s; strcpy(s.str, "foo"); Beware strcpy may cause a buffer overflow...


Thank you so much. And why we are using always int main in structure ?. Can we use void type?