Section 7.11 Check Point Questions3 questions
7.11.1
What are the differences between the following arrays?
char s1[] = {'a', 'b', 'c'}; char s2[] = "abc";
7.11.2
Suppose s1 and s2 are defined as follows:
char s1[] = "abc"; char s2[] = "efg";Are the following expressions/statements correct?
a. s1 = "good" b. s1 < s2 c. s1[0] d. s1[0] < s2[0] e. strcpy(s1, s2) f. strcmp(s1, s2) g. strlen(s1)
7.11.3
Why is the following code incorrect? How do you fix it?
char s[80] = "abc 123 aABC"; int count = 0; for (int i = 0; i < 80; i++) { if (isalpha(s[i])) count++; } cout << "The number of letters in s is " << count << endl;