Skip to main content

Posts

Showing posts from September, 2018

What is a Pointer in C?

Create a variable Let's create a variable and give it a value of 3. int a; a = 3 ; Variable  a 's info Name a Value 3 Data Type The data type  of a variable tells you what kind of data it will hold. We can see in the code above that variable a is an int. int = holds an integer (aka a whole number) char = holds a single character pointer = holds a memory address Variable  a 's info Name a Data Type int Value 3 Memory Address The  a  variable is stored somewhere in your computer's memory. Just like humans have an address, variables have an address too. ( 0x00008130 is just an example address, your variable will probably have a different address) Pointers A pointer holds this memory address-- so basically it POINTS to where a variable is located. Let's create a pointer that will point to where our a variable is located. To create a pointer, we need the data type of the variable we will be