[Solved] What is the difference between char *ptr = “hi”; int *ptr = “100”? [closed]


Unless you’re really know what you’re doing and have some special plan, what you’re doing does not make sense.

int *ptr = "100" is basically just a shortcut for this:

char *tmp = "100";
int  *ptr = tmp;

To avoid the warning, you need to do this:

int  *ptr = (int*) tmp;

But don’t do this.

2

solved What is the difference between char *ptr = “hi”; int *ptr = “100”? [closed]