#include int main(void) int arr<10>; arr = "Hello"; printf("%s",arr); return 0;The above code shows compiler error:

t.c: In role ‘main’:t.c:5:9: error: assignment to expression through array type arr = "Hello"; ^t.c:6:12: warning: style ‘%s’ expects dispute of kind ‘char *’, however argument 2 has kind ‘int *’ <-Wformat=> printf("%s",arr); ^Whereas the listed below code works fine.

You are watching: Error assignment to expression with array type

#include int main(void) char arr<10> = "Hello"; printf("%s",arr); return 0;Both look the same to me. What am I lacking here?

They are not identical.

First the all, it provides zero feeling to initialize one int selection with a cable literal, and in worst case, it might invoke unknown behavior, as reminder to creature conversion and also the validity that the converted result thereafter is extremely platform-specific behaviour. In this regard, both the snippets space invalid.

Then, correcting the data type, considering the char array is used,


Don"t know just how your 2nd code is working (its not functioning in my instance PLEASE phone call ME WHAT can BE THE REASON) it is saying: selection of inappropriate kind (int) initialized with string constant

Since girlfriend can"t just assign a whole string to a creature variable.but you can assign a single character to a int change like:int a<5>="a","b","c","d","d"


Thanks because that contributing solution to ridge Overflow!

Please be certain to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to various other answers.Making statements based upon opinion; ago them increase with recommendations or personal experience.

See more: Does Apple Juice Make A Pregnancy Test Positive ? Ways To Fake Your Pregnancy Test

To learn more, check out our tips on writing an excellent answers.

short article Your price Discard

By clicking “Post her Answer”, you agree to our regards to service, privacy policy and also cookie plan


site style / logo design © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.11.5.40661

Stack Overflow works ideal with JavaScript allowed

her privacy

By click “Accept every cookies”, girlfriend agree ridge Exchange can store cookie on your device and disclose info in accordance through our Cookie Policy.