- 1
Could anyone explain why we can't assign string directly through = operator in structure concept in C programming
3 Respostas
+ 1
in the latest standard only int main() is allowed
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...
0
Thank you so much. And why we are using always int main in structure ?. Can we use void type?