Basics of C++ Pointers and Examples with Strings

What is a pointer?

A pointer is a variable that stores the memory address as its value.

‘&’ is used to get the memory address of the variable.

‘*’ is used to store the memory address of the variable.

How are pointers used?

Here is an example of how to use a pointer in cpp. A variable is first declared with the string “Pizza”. The memory address of the variable ‘food’ is retrieved with ‘&’. How do we store a pointer into…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store