CPS 196 week 11

CPS 196 week 11 - CPS Week 11 Nov 7 11 Character Strings...

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

View Full Document Right Arrow Icon
CPS Week 11 Nov 7 11 Character Strings printf(“hello”); string of characters composed of ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ in C, strings are just array of characters example: (0-4) Need to know length of string before hand Variable Length Character string -to handle any length of string C uses a special charater character called “null” (‘\0’) to denote the end of string printf(“%s”, str); -- make sure with ‘\0’ How to initialize character string char str[ 6 ]= {‘h’, ‘e’, ‘l’, ‘l’, ‘o’, ‘\0’}; or char str2[]=”Hello”; don’t have to identify any characters Character Strings Output spaces and symbols are characters also c automatically puts in null characters Character Strings Input char word[100];
Background image of page 1

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

View Full DocumentRight Arrow Icon
printf(“please enter a word:”); scanf(“%s”, %word); Screen BUT this has trouble with spaces. it will ignore everything after the space. have to do t
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/16/2012 for the course CPS 196 taught by Professor Staff during the Spring '08 term at Syracuse.

Page1 / 4

CPS 196 week 11 - CPS Week 11 Nov 7 11 Character Strings...

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

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