It's UWAweek 42 (2nd semester, week 12)

help2002

This forum is provided to promote discussion amongst students enrolled in CITS2002 Systems Programming.
Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.
Displaying the 1 article in this topic
Showing 1 of 688 articles.
Currently 6 other people reading this forum.


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful

Hi, the way I remember it is that * refers to a pointer if a datatype comes before it e.g. int*. If there is no type beforehand, then * is the dereference operation.

e.g. int* p, declares a pointer to an int. *p refers to the value stored at p.

Works for function definitions

int* somefunction(char* string)

Function takes in a pointer to a character and returns a pointer to an int.

Another helpful way to think of pointers is to think about houses:

  • If you have a house, you can write down its address (using address = &house).
  • If you follow an address, you can follow it to get to the house (using house = *address).
  • You can write down the address to the same house multiple times.
  • If you want work done on your house you need to pass your address.
  • Just because two houses look the same doesn't mean they have the same address.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy