Exam 12: More on C-Strings and the String Class

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

To declare a C-string, you should use the type expression string *.

Free
(True/False)
4.9/5
(39)
Correct Answer:
Verified

False

The following statement declares a string object and initializes it to "Once upon a time". string theString("Once upon a time");

Free
(True/False)
4.8/5
(33)
Correct Answer:
Verified

True

The proper expression to compare the first characters of two string objects str1 and str2 is

Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
Verified

B

Which statements convert the string "10" to the integer value 10?

(Multiple Choice)
4.9/5
(32)

Assume that str1 and str2 are variables of type C-string. The proper expression to use when comparing them for equality is

(Multiple Choice)
4.8/5
(34)

The string class append member function str.append(s)tacks a string s to the end of str.

(True/False)
4.8/5
(33)

To account for the null terminator stored at the end of each C-string, the strlen function returns the number of characters in its argument, plus one.

(True/False)
4.9/5
(37)

Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.

(True/False)
4.8/5
(38)

A good way to convert a value of type double to a string is

(Multiple Choice)
4.9/5
(35)

The code int x = 0; while (s[x] != 0) { x++;}

(Multiple Choice)
4.9/5
(37)

The >> operator can be used to convert a value of type double to an equivalent string object stored in memory.

(True/False)
4.8/5
(41)

The expression strcmp("ab", "cde") returns

(Multiple Choice)
4.8/5
(26)

By being able to pass arrays as arguments, you can write your own functions for processing C-strings.

(True/False)
4.9/5
(39)

The C++ compiler performs strict array bounds checking whenever an array of characters is being accessed.

(True/False)
4.7/5
(30)

The string class member function ________ will return the number of characters in the string object.

(Multiple Choice)
4.8/5
(32)

The expression str1 < str 2 is True when

(Multiple Choice)
4.7/5
(38)

The strcpy function's arguments are

(Multiple Choice)
4.8/5
(33)

The string class overloads the += operator to perform

(Multiple Choice)
4.8/5
(33)

The string class member function ________ returns the C-string value of the string object.

(Multiple Choice)
4.8/5
(35)

Assume that str1 and str2 are objects of the string class. The proper expression to use when comparing them for equality is

(Multiple Choice)
4.8/5
(32)
Showing 1 - 20 of 40
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)