This is very easy an individual array element is

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t. This is very easy, an individual array element is accessed like array_name[index]; and can be treated exactly as a variable. So say we would like to make one of our array elements 5 we could do so like this: array_name[3]=5; We can even make array elements equal to other array elements as such: array_name[2]=array_name[3]+5; SIZE OF AN ARRAY As covered in class to determine the length of an array we do: sizeof(array)/sizeof(array element); Please refer to lecture notes 10 for an explanation why. STRINGS You may recall that it is possible to have characters in C. A character is a single letter like ‘a’ or ‘F’. A group of characters, or a word, is called a string in C. DECLARATION There is actually no data type reserved for strings in C. Instead we create arrays of character which serve the same purpose. We would declare a word, or sentence as follows: char string_name={“Sentence or word contained in quotes”}; The last element of this array actually contains a null terminator (\0), which is something the computer puts in by default to indicate that...
View Full Document

This note was uploaded on 05/06/2013 for the course COMP SCI 3312 taught by Professor Vrbik during the Winter '11 term at UWO.

Ask a homework question - tutors are online