can someone explain the following? i am newbie, not sure what does char a='x'...

lichen

New member
Joined
Sep 1, 2009
Messages
1
Reaction score
0
Points
1
...do? and how ++(*a) being y? char a='x';
cout <<&a<<endl;
char *b = &a;
cout <<++(*b)<<endl;
since char type is array,

char a[] = "x"; makes sense, i am confused about char a ='x';

++(*b) really is auto_casting the char to asci number, but how did it convert back? i thought i need char(++(*b))?
 
char a='x'; creates a variable that can store a single character; the variable is named a and it is initialized with the character/value 'x'.

++(*a); increases the value of the contents of variable a, by one. Since the original value was x, it now becomes y. Change the ++ to -- (two minuses) and the value will be decreased, resulting in the letter w.
 
Back
Top