l11_6up - CSci 1113 C/C for Scientists and Engineers...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
: CSci 1113 C/C++ for Scientists and Engineers Section 010 - evening class Exam Review, C and C++ strings Prof. Eric Van Wyk and Ted Kaminski Spring 2010 c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 1 / 35 : Agenda review for midterm exam strings as char arrays The C++ string class begin dynamic memory allocation and pointers. c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 2 / 35 Lab midterm exam review : Logistics Two hours: 90 minutes for exam and 30 minutes for grading. Open book, notes, lab files, course web pages. A web browser can be connected to the course website. Be sure to get all the code you’ve written with your lab partner. You can ask a TA about a ”syntax” problem. e.g., what does this error message mean? If you finish early, your exam can be graded but in silence. c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 3 / 35 Lab midterm exam review : Coverage Material covered: chapters 1-5 and 12 of the text. Functions, Arrays, File I/O and streams. Be able to write complete working programs that use these features. Significant points allowed for partial work. See the online review document and sample exam. c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 4 / 35 C-style strings : C and C++ strings There are two implementations of strings in C++. 1. The old version inherited from C. 2. The new class-based C++ version. c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 5 / 35 C-style strings : C-style strings Implemented as an array of characters. The length is not explicitly specified. The end of the string is indicated by the character \ 0 . char s[10]; This holds a string of at most 9 characters. One extra is needed for the “sentinel” \ 0 . How is “Hi Mom!” represented this way? c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 6 / 35
Image of page 1

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

View Full Document Right Arrow Icon
C-style strings : ASCII ASCII - American Standard Code for Information Interchange A mapping of characters to integer values. The character ’H’ is represented by integer 72, a space is 32. See the Wikipedia table. See ASCII.cpp . Let’s add a length function. c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 7 / 35 C-style strings : Exercise 11.1 What is a function declaration for a function that concatenates two C-strings to create a third? c Van Wyk and Kaminski CSci 1113: C/C++ for Scientists and Engineers, evening class Spring 2010 Page 7 / 35 C-style strings : Exercise 11.2 Sketch the definition of this function.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern