How can a char pointer be initialized with a string (Array of characters) but an int pointer not with an array of integer? [duplicate]

Because these are the rules (standards) of the language. There’s nothing telling you it’s possible to initialize a pointer with an array like this, for example, the following is also illegal:

char* name={'m', 'i', 'k', 'h', 'i', 'l', 0};

A literal string gets its own treatment and is not defined just as an array of characters.

Leave a Comment