Lecture 4 - Memory

Hexadecimals

For example

Memory addresses

Pointers

A second use for asterix operator

The asterix can also be used when we want to not use the address of a variable, but if we have an address and want to see what the variable it is pointing to

The String datatype

malloc and free

Copying variables - if we copy one string to another, we aren’t actually creating another copy, we are just copying over the address. So each variable will point to the same data in memory

The valgrind command can be used in the Command Line interface when running program to analyse memory use of program and detect errors

As i have noticed in debugger, before you initialise values to have a value in program, when initialised they sometimes contain a random number. this is called a garbage value.

Copying values always requires some temporary space to hold one of the variables

Scope

In previous weeks we covered the concept of scope, because sometimes arrays have only been limited to the function in which they were called or initialised

Swapping variable values

scanf, the true get_string/int/float

FILE INPUT / OUTPUT

within see we can use pointers to files and the FILE data type to call files within program, allowing us to open, print and write to files.