cs31f08dis6

cs31f08dis6 - CS31: Introduction to Computer Science I...

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

View Full Document Right Arrow Icon
Discussion 1J Notes (Week 6, May 9) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 C Strings C++ has an older brother, whose name is C. (As you might know ++ is an incremental operator, hence the extended version of C was named “C++”). In C, we did not have the data type string , and C had its own way of representing strings. However, C++ inherited this older way of representing strings from C, and these old strings are still widely being used. Therefore, we are teaching you this, and these old strings are called “C-strings” for the above reason. Recall that a string is a sequence of zero or more characters . Also recall that an array is a sequence of variables of the type you deFne. Combing the two, we can use an array of characters to represent a string. Let us define a string as follows: char s[10]; This creates space for a string of length 9. Wait, why 9, not 10? Every C-string must end with a marker that says “this is the end of the string.” Otherwise, it is nothing but
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.

Page1 / 3

cs31f08dis6 - CS31: Introduction to Computer Science I...

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