1 / 8

ENEE150 Recitation 5

ENEE150 Recitation 5. Quiz 2. Good luck!. Pointers. Pointer declaration Memory address Accessing pointer memory Array names are pointers Pointer arrays Case 1 i nt a, b, c; int *pa1[3] = {&a, &b, &c}; Case 2 int d[10], e[12], f[5]; i nt *pa2[3] = {d, e, f} What is pa2?.

sawyer
Download Presentation

ENEE150 Recitation 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENEE150 Recitation 5

  2. Quiz 2 • Good luck!

  3. Pointers • Pointer declaration • Memory address • Accessing pointer memory • Array names are pointers • Pointer arrays • Case 1 • int a, b, c; • int *pa1[3] = {&a, &b, &c}; • Case 2 • int d[10], e[12], f[5]; • int *pa2[3] = {d, e, f} • What is pa2?

  4. Incrementing and decrementing pointers changes the memory address by the size of the variable type (ie. char, int, float) • Array names are pointers • caution.c • ptr_arith.c

  5. Homework 2 • Problem 1 – Test vectors • Test 7 functions in required_functions.o • Think of .o file as .c file except you can’t read the code • Can include checkers.h since you need definitions, etc. • Initialize board • Print board (may have to do this more than once) • Run functions • Look at output file to see what tests need to be made for each function • gcc test1-driver.c required_functions.o

  6. Homework 2 • Problem 2 – Script • Use a for loop…it makes things easier • foreachi (1 2 3 4) • $i • end • a.out > outputfile • Changes stdout to the output file instead of the screen • diff <file1> <file2> • Shows the difference between the files • echo “hello” • Prints out “hello” to the screen

  7. Exercise 1 • Try creating an array of 5 integers and then incrementing each element

  8. Exercise 2 • Try inputting an integer pointer from main into a function, change the contents of the integer (that the pointer is pointing to) within that function, and then print out the integer value in main

More Related