Tip:
Highlight text to annotate it
X
Colin Goble: Hello again. This is Colin Goble.
In this program, I will try to show you
how to use the standard C-string library in C++
to manipulate old style C-strings.
The library itself is right here.
You can look it up on cplusplus.com. [Pronounced: C plus plus dot]
It used to be called 'string.h.' [Pronounced: String-dot-H]
In the new ANSI standard, [Pronounced: An-see]
# include cstring [Pronounced: pound-include-c-string]
which I will show you in the program.
Here are some of the functions that we are going to use.
We are going to be comparing two strings
and we are going to be copying some strings.
There are many other things in the standard library
as you can see.
But, copying strings and comparing strings
is what this application is going to focus on doing.
Okay. So in this demonstration of old style strings,
I referenced the standard 'cstring' library.
That is the URL.
And you can look up all of the various other functions
that are available there.
And I have included ‘cstring’.
It used to be called ‘string.h’.
In the new ANSI standard,
the '#include' is to 'cstring.' [Pronounced: pound-include]
As in my previous program, the first array is called 'string1.'
It contains the characters "Hello World!"
And as before, C++ automatically adds a zero [0],
a null terminating 0 byte at the end.
So the length of the 'string1' array
is actually 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 characters
for Hello World!, including the exclamation point.
Plus 1, it is a 13 byte array.
This program then outputs that array
using the standard stream insertion operator,
less than, less than[