Lecture 3

Note that the order is inversed relative to a two d

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: numbers[0] ... first column • my_numbers[0][1] ... second number in the first column. (Note that the order is inversed relative to a two-D array.) 9 Strings • A string is an array of characters. • Literal strings are written as “abcd” • The compiler adds a ‘ to the end of a \0’ literal string. Thus the array has to be by one larger than the largest text string. • Strings are are assigned with strcpy(target,source) from “string.h” 11 10 More on Strings • strcmp(S1, S2) returns 0 if two strings are the same. It returns a negative number if S1 is before S2, and a positive number otherwise. • strcat(S1, S2) appends S2 to the end of S1 and returns S1. In other words, it is sideeffecting. 12 String I/O • Strings can be read with cin >> if no white space is contained in them. • Strings can be written with cout << • cout....
View Full Document

Ask a homework question - tutors are online