Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Fundamentals. Today’s Lecture Multidimensional Arrays Arrays as Class Member Data Arrays of Objects C-Strings.

Similar presentations


Presentation on theme: "Programming Fundamentals. Today’s Lecture Multidimensional Arrays Arrays as Class Member Data Arrays of Objects C-Strings."— Presentation transcript:

1 Programming Fundamentals

2 Today’s Lecture Multidimensional Arrays Arrays as Class Member Data Arrays of Objects C-Strings

3 Multidimensional Arrays

4

5

6 Passing Arrays to Functions

7 OUTPUT???

8 Arrays of Structures

9

10

11 Arrays as Class Member Data

12

13 Arrays of Objects

14

15 C-Strings

16

17 C-String Variables Each character occupies 1 byte of memory. An important aspect of C-strings is that they must terminate with a byte containing 0. This is often represented by the character constant ‘\0’, which is a character with an ASCII value of 0. This terminating zero is called the null character. When the << operator displays the string, it displays characters until it encounters the null character.

18 Avoiding Buffer Overflow

19 String Constants

20 Reading Embedded Blanks It turns out that the extraction operator >> considers a space to be a terminating character. Thus it will read strings consisting of a single word, but anything typed after a space is thrown away.

21 Reading Embedded Blanks To read text containing blanks we use another function, cin.get(). This syntax means a member function get() of the stream class of which cin is an object.

22 Reading Multiple Lines

23 Copying a String the Hard Way

24 Copying a String the Easy Way

25 Arrays of Strings

26

27 The Standard C++ string Class Standard C++ includes a new class called string. You can concatenate string objects with the + operator:

28 Defining and Assigning string Objects

29 Input/Output with string Objects

30

31 Finding string Objects

32 Questions???


Download ppt "Programming Fundamentals. Today’s Lecture Multidimensional Arrays Arrays as Class Member Data Arrays of Objects C-Strings."

Similar presentations


Ads by Google