Chapter10 - Chapter 10 Strings 1 Dr Serdar Kirli String...

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

View Full Document Right Arrow Icon
Dr. Serdar Kirli 1 Chapter 10 Strings
Background image of page 1

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

View Full Document Right Arrow Icon
String Object Example 1 #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); if (color == "red" ){ cout<<endl<< "This is a ” <<color1<< “car!" ; } if (color != color2){ cout << endl << "I do not like this car!" ; } cout << endl; system( "PAUSE" ); return 0 ; }
Background image of page 2
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car
Background image of page 3

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

View Full Document Right Arrow Icon
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1
Background image of page 4
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1 b l u e color2
Background image of page 5

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

View Full Document Right Arrow Icon
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1 b l u e color2 g o l d color3
Background image of page 6
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1 b l u e color2 g o l d color3 0 12
Background image of page 7

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

View Full Document Right Arrow Icon
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1 b l u e color2 g o l d color3 13 start 0 12
Background image of page 8
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){ string car = "72 Mustang, (red)" ; string color1 = "red" ; string color2 = "blue" ; string color3 = "gold" ; int start = car.find( "(" ) + 1 ; int end = car.find( ")" ); int length = end - start; string color = car.substr(start, length); car r e d color1 b l u e color2 g o l d color3 13 start 0 16
Background image of page 9

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

View Full Document Right Arrow Icon
String Object Example 1 7 2 M u s t a n g , ( r e d ) #include <iostream> #include <cstdlib> #include <string> using namespace std; int main( void ){
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 128

Chapter10 - Chapter 10 Strings 1 Dr Serdar Kirli String...

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

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