Exercise 3.37
#include<iostream>
using namespace std;
int main()
{
const char ca[] = {
'h','e','l','o' };
const char* cp = ca;
while (*cp)
{
cout << *cp << endl;
++cp;
}
}
After outputting the index of the array ca, continue to output subsequent adjacent storage space values until encountering'\0'
Exercise 3.38
Pointer points to address, address addition is meaningless
Exercise 3.39
#include<iostream>
using namespace std;
int main()
{
string s1("Hello"), s2("world");
const char ca[] = "adjacent";
const char cb[] = "incident";
if (s1 < s2)
cout << "true";
else
cout << "false";
if (strcmp(ca, cb))
cout << "true";
else
cout << "false";
}
Exercise 3.40
#include<iostream>
using namespace std;
int main()
{
const char ca[] = "adjacent";
const char cb[] = "incident";
char cc[50];
strcpy(cc, ca);
strcat(cc, cb);
}