Should a pointer contain variable address of same datatype ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Should a pointer contain variable address of same datatype ??

char a='h'; int b=&a; does this is correct??

3rd Sep 2017, 11:37 AM
Harsha Sanju
Harsha Sanju - avatar
2 Answers
+ 8
Nope. Pointer datatype has to be obeyed. You store the address of a character variable using a char pointer.
3rd Sep 2017, 1:01 PM
Hatsy Rei
Hatsy Rei - avatar
0
ok if I place *b=&a; then it is also wrong.... yes??
3rd Sep 2017, 1:42 PM
Harsha Sanju
Harsha Sanju - avatar