Assignment to expression with array type
Error Message:
Main.c:8:13: error: assignment to expression with array type
Alphabets=’A’;
Error Description:
#include#include int main() { char alphabets[25]; //Array is not indexed alphabets='A'; printf("contents of Array index of 0 is : %c \n", alphabets[0]); return 0; }
In above code there is an issue, alphabets is an array,
cannot directly assign without index,
alphabets="A";
Error Solution:
Need to use index with array for the assignment like alphabets[0]='A';
#include#include int main() { char alphabets[25]; alphabets[0]='A'; printf("contents of Array index of 0 is : %c \n", alphabets[0]); return 0; }
Output:

Post a comment
Please share your valuable feedback and share this article in social media.