Chapter 2.5. Strings: String theory
Thereâs more to strings than reading them.
Youâve seen how strings in C are actually char
arrays but what does C
allow you to do with them? Thatâs where string.h comes in.
string.h is part of the C Standard Library thatâs
dedicated to string manipulation. If
you want to concatenate strings
together, copy one string to
another, or compare two strings,
the functions in string.h are there to help. In this
chapter, youâll see how to create an array of
strings, and then take a close look at how to search within strings using the strstr()
function.
Desperately seeking Susan Frank
There are so many tracks on the retro jukebox that people canât find the music they are looking for. To help the customers, the guys in the Head First Lounge want you to write another program.
This is the track list:
The list is likely to get longer, so thereâs just the first few tracks for now. Youâll need to write a C program that will ask the user which track she is looking for, and then get it to search through all of the tracks and display any that match.
Brain Power
Thereâll be lots of strings in this program. How do you think you can record that information ...
Get Head First C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.