{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

LECTURE_9_CS113_2010

# LECTURE_9_CS113_2010 - CSC 113 Lecture 9 Strings Strings A...

This preview shows pages 1–7. Sign up to view the full content.

CSC 113 Lecture 9 Strings

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

View Full Document
Strings A string is an array of characters – s = 'abc' is equivalent to s = [ 'a' 'b' 'c' ] All operations that apply to vectors and arrays can be used together with strings as well – s(1) 'a' – s( [ 1 2 ] ) = 'XX' s = 'XXc' – s(end) 'c'
String Conversion Conversion of strings to numerical arrays – double ( 'abc xyz' ) ans = 97 98 99 32 120 121 122 – double ( 'ABC XYZ' ) ans = 65 66 67 32 88 89 90 Conversion of numerical arrays to strings – char ( [ 72 101 108 108 111 33 ] ) ans = Hello!

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

View Full Document
String Tests ischar() : returns 1 for a character array ischar ( 'CS 113' ) ans = 1 isletter() : returns 1 for letters of the alphabet isletter( 'CS 113' ) ans = 1 1 0 0 0 0 isspace() : returns 1 for whitespace (blank, tab, new line) isspace( 'CS 113' ) ans = 0 0 1 0 0 0
String Comparison Comparing two characters – 'a' < 'e' ans = 1 Comparing two strings character by character – 'fate' == 'cake' ans = 0 1 0 1 – 'fate' > 'cake' ans = 1 0 1 0

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

View Full Document
String Comparison strcmp() : returns 1 if two strings are identical – a = 'Bilkent'; – strcmp( a, 'Bilkent' ) ans = 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern