Why this error with pointers?

Check this pic:

http://img263.imageshack.us/img263/2273/cpppointererrorchar2int.jpg

So, what's the real reason that this happen (types doesn't mind).
Last edited on
Types do matter, you need to cast &h to an int* or use a pointer to char
As the error states " You are trying to convert char * to int *"

use
 
char *p = &h; 
Yes, i know that, but my question is because that, what's the way, i.e., why don't convert the letter to the integer of ASCII.
You want to get the ASCII value of '5' ?
You just need to convert the character in a different numeric type
eg:
1
2
3
char h = '5';
int i = h;
int j = '5'; // you can just assign the character literal to an integer  
your p variable is a pointer on a integer, so later on with p=&h your trying to make it point on a char variable, which can not be done since its already an pointer on a integer ..
Topic archived. No new replies allowed.