Sams Teach Yourself C in 21 Days

(singke) #1

DAY 17


WEEK 3


Manipulating Strings


Text data, which C stores in strings, is an important part of many programs. So
far, you have learned how a C program stores strings and how you can input
and output strings. C offers a variety of functions for other types of string
manipulations as well. Today you will learn


  • How to determine the length of a string

  • How to copy and join strings

  • Functions that compare strings

  • How to search strings

  • How to convert strings

  • How to test characters


Determining String Length ................................................................................


You should remember from earlier lessons that, in C programs, a string is a
sequence of characters, with its beginning indicated by a pointer and its end
marked by the null character \0. At times, you need to know the length of a

28 448201x-CH17 8/13/02 11:13 AM Page 481

Free download pdf