exp5 - Hacettepe University Department Of Computer...

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

View Full Document Right Arrow Icon
Hacettepe University Department Of Computer Engineering Bil137 Computer Laboratory Fall 2009 Experiment 5 Subject : Pointer Arithmetic Submission Date : 08 .1 2 .2009 Due Dat e : 15 . 12 .2009 Advisors : Oğuz ASLANTÜRK R.A. Yasin ŞAHİN Programming Language : C 1. AIM : In this experiment, you will develop a program by using pointer arithmetic. And you will have a chance to learn some details of memory addressing logic of C and computers with this experiment. 2.BACKGROUND An array is a sequence of objects, each of the same data type. The starting address of this array of objects, i.e. the address of the first object in the array is called the base address of the array. The address of each successive element of the array is offset from the base by the size of the array type, e.g. for each successive element of an integer array, the address is offset by the size of an integer type object. In C, the name of an array used by itself in an expression evaluates to the base address of the array. That is, this value is a pointer type and points to the first object of the array. The name of the array is said to point to the array. If the array is an integer array, (float array, character array, etc.) then the type of X is int * ( float *, char *, etc.). Thus, the declaration of an array causes the compiler to allocate the specified number of contiguous cells of the indicated type, as well as to allocate an appropriate pointer cell, initialized to point to the first cell of the array. This pointer cell is given the name of the array. Since X points to X[0], the
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2010 for the course QWE qwe taught by Professor Qwe during the Spring '09 term at Amarillo College.

Page1 / 5

exp5 - Hacettepe University Department Of Computer...

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

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