- 1

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

3rd Oct 2019, 8:52 AM
madhumathi
3 Réponses
+ 1
in the latest standard only int main() is allowed
3rd Oct 2019, 1:04 PM
✳AsterisK✳
✳AsterisK✳ - avatar
0
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...
3rd Oct 2019, 10:43 AM
jtrh
jtrh - avatar
0
Thank you so much. And why we are using always int main in structure ?. Can we use void type?
3rd Oct 2019, 11:28 AM
madhumathi