(upbeat music)
- [Instructor] For this challenge,
you will exercise your knowledge of basic C++ syntax
by counting the number of characters in a C string.
You'll find this partial C++ program,
02_challenge.cpp, in the Chapter 02 exercise files.
Here, I've declared a string,
and I've declared an integer for counting,
and I've constructed a printf that will count the number
of characters.
You notice if I build and run this,
it says there's zero characters.
And you'll notice I have a warning here:
unused variable string.
This is a partial program.
This is not complete.
What you're going to need to do is you're going
to need to come in in between these lines
and create a loop that will count the characters
in the string.
Remember that a C string is just an array
of characters with a zero terminator at the end.
This is called a null-terminated string.
This is a common problem in the real world,
so it's a useful exercise to learn.
This challenge has several possible solutions.
So take your time and experiment a bit.
The purpose is to use your knowledge of basic C++ syntax.
Expect this to take you 10 minutes or so,
and I'll present a few possible solutions
in the next lesson.