Chapter 8: Problem 14
Consider the following code (and assume it is embedded in a complete and
correct program and then run):
char my_string[80];
cout << "Enter a line of input:\n";
cin.getline(my_string, 6);
cout << my_string << "
Chapter 8: Problem 14
Consider the following code (and assume it is embedded in a complete and
correct program and then run):
char my_string[80];
cout << "Enter a line of input:\n";
cin.getline(my_string, 6);
cout << my_string << "
All the tools & learning materials you need for study success - in one app.
Get started for freeinclude
What C string will be stored in singing_string after the following code is run? char singing_string[20] = "DoBeDo"; strcat(singing_string, " to you"); Assume that the code is embedded in a complete and correct program and that an include directive for \(< c\) string \(>\) is in the program file.
What string will be output when this code is run? (Assume, as always, that this code is embedded in a complete, correct program.) char song[10] = "I did it "; char franks_song[20]; strcpy ( franks_song, song ); strcat ( franks_song, "my way!"); cout << franks_song << endl;
Which of the following declarations are equivalent? char string_var[10] = "Hello"; char string_var[10] \(=\left\\{^{\prime} \mathrm{H}^{\prime},^{\prime} \mathrm{e}^{\prime},^{\prime} \mathrm{L}^{\prime},^{\prime} \mathrm{l}^{\prime}, \text { ' o' },^{\prime} \backslash \theta^{\prime}\right\\} ;\) char string_var[10] \(=\left\\{^{\prime} \mathrm{H}^{\prime},^{\prime} \mathrm{e}^{\prime},^{\prime} \mathrm{l}^{\prime},^{\prime} \mathrm{l}^{\prime}, \text { 'o' }\right\\} ;\) char string_var[6] = "Hello"; char string_var[] = "Hello";
Suppose the function strlen (which returns the length of its string argument \()\) was not already defined for you. Give a function definition for strlen. Note that strlen has only one argument, which is a C string. Do not add additional arguments; they are not needed.
What do you think about this solution?
We value your feedback to improve our textbook solutions.