rec2-2010 - Today C Programming Review 1. Arrays 2....

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Today C Programming Review 1. Arrays 2. Pointers 3. Memory Allocation 4. Structures Compilation and Make
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
C Programming Review C programming will be used heavily throughout this course throughout all assignments. If you haven't programmed in C before, now is the time to learn!! There are tutorials on the course website and all over the Internet. We will review some C basics to refresh our minds.
Background image of page 2
C Programming - Review Here is a simple C program: #include <stdio.h> int main (int argc, char *argv[]) { printf(“Hello World!\n”); return 0; } The value argc is the number of the arguments including the command, and argv is an array of strings containing each argument.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Arrays in C Arrays are used to group data consecutively in memory and to provide an easy access to them. int array[10]; int my_ints[] = {4, 5, 10, 27}; int i; for( i = 0; i < 4; i++) printf(“my_ints[%d] is %d” , i, my_ints[i]); C allows 2-dimensional and high dimensional arrays. How are they stored in memory and how to access the elements?
Background image of page 4
Pointers in C Pointers are used to reference variables by their address instead of by name. The *operator is used to dereference a pointer, address of a variable. int m = 7; int *p; //declare a pointer variable p = &m; // p now points to m *p = *p + 3;// m is 10 now
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Pointers in C Don't get confused about where the * is used. In
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 18

rec2-2010 - Today C Programming Review 1. Arrays 2....

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online