Why it is possible to assign string to character pointer in C but not an integer value to an integer pointer
why in the below code int *p = 22 will give compile time error and ptr will print the value successfully . int main() { /*taking a character pointer and assigning a string to it*/ char *ptr = "Stackoverflow" ; //correct /*taking a int pointer and assigning a string to it*/ int *p = 22 ; //incorrect printf("%s",ptr); // correct and print printf("%d",p); //incorrect and give compile time error. return 0; } If you have a character array as for example char s[] = "Stackoverflow"; then the array designator used in expressions it is converted to pointer to its first element. So you may write char