Lecture 2 - Strings

Lecture 2 - Strings - WorkingwithStrings Lecture2...

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

View Full Document Right Arrow Icon
Working with Strings Lecture 2 Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/˜ hkaiser /fall_2011/csc1254.html  
Background image of page 1

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

View Full DocumentRight Arrow Icon
Abstract This lecture will look at strings. What are  strings? How can we input/output strings? How  can we manipulate strings? What functionality is provided by the  std::string  type? 8/25/2 011,  Lecture  2 CSC1254,  Fall 2011,  Strings 2
Background image of page 2
C++ Libraries Groups related operations Header file provides function prototypes and usage  comments Compiled library contains implementation C++ Standard Libraries E.g. string, iostream, fstream #include <foo> Terse lowercase names: cout, getline, substr 8/25/2 011,  Lecture  2 CSC1254,  Fall 2011,  Strings 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
String Input Given the following interaction: Please enter your name: John We would like to print: Hello John! 8/25/2 011,  Lecture  2 CSC1254,  Fall 2011,  Strings 4
Background image of page 4
String Input // Ask a persons name, greet the person #include <iostream> #include <string> int main() { // ask for the persons name 8/25/2 011,  Lecture  2 CSC1254,  Fall 2011,  Strings 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
String Input Place to put input into:  variable Variables are objects which have a name  ( first_name ) Objects are part of the computer memory with an  associated type ( std::string ) std::string Part of  namespace std #include <string> 8/25/2 011,  Lecture  2 CSC1254,  Fall 2011,  Strings 6
Background image of page 6
String Input Variable  definition:  std::string name; Local variable, is destroyed at end of block Type defines the available operations and interface 
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/29/2011 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 21

Lecture 2 - Strings - WorkingwithStrings Lecture2...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online