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 in C?
Create an array ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access