EEE 0115 Chapter 8 C Characters and Strings

  • Slides: 13
Download presentation
EEE 0115 Chapter 8: C Characters and Strings 1 C How to Program Deitel

EEE 0115 Chapter 8: C Characters and Strings 1 C How to Program Deitel & Deitel

2 Outline Fundamentals of Strings and Characters Character-Handling Library String-Conversion Functions Standard Input/Output Library

2 Outline Fundamentals of Strings and Characters Character-Handling Library String-Conversion Functions Standard Input/Output Library Functions String Manipulation Functions String Comparison Functions

3 Fundamentals of Strings and Characters Character constant is an int value represented as

3 Fundamentals of Strings and Characters Character constant is an int value represented as a character Strings A series of characters considered as a single unit String literal is written in double quotes "Hello" Basically strings are arrays of characters The actual value of string is the address of first character

4 Fundamentals of Strings and Characters String definitions Define as a character array or

4 Fundamentals of Strings and Characters String definitions Define as a character array or a variable of type char * char color[] = "blue"; char *color. Ptr = "blue"; Strings represented as character arrays end with ‘’ color variable has 4+1=5 elements To input strings using scanf: scanf("%s", word);

5 Character-Handling Library (ctype. h)

5 Character-Handling Library (ctype. h)

6 Character-Handling Library

6 Character-Handling Library

7 Character-Handling Library

7 Character-Handling Library

8 String-Conversion Functions (stdlib. h)

8 String-Conversion Functions (stdlib. h)

9 Standard Input/Output Library Functions (stdio. h)

9 Standard Input/Output Library Functions (stdio. h)

10 String Manipulation Functions (string. h)

10 String Manipulation Functions (string. h)

11 String Comparison Functions (string. h)

11 String Comparison Functions (string. h)

12 String Comparison Functions (string. h)

12 String Comparison Functions (string. h)

13 String Comparison Functions (string. h)

13 String Comparison Functions (string. h)