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

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: CSC 113 Lecture 9 Strings 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! 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 String Comparison...
View Full Document

This note was uploaded on 02/29/2012 for the course CSC 113 taught by Professor Phillipregali during the Fall '10 term at Catholic University of America.

Page1 / 14

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

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

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