2 Answers
New AnswerA pointer is a variable that points to a memory location. You can create a pointers like this: int x = 5; int* y = &x; & is used to access the variable's memory location, and the int* means that y will point to an integer. y will track x, no matter what. Printing y will mostly give you a "nonsensical" number, since it is the memory location, and you can't do anything with it. To actually show the value, you have to again use the asterisk: printf("%d", *y); //This will output 5
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message