There are several uses of the getline function. Assume the definition, string line1, line2; Which one of these allows specification of the character on which input stop?
a. cout << “Enter a line of input \n”;
getline(cin, line1);
b. cout << “Enter a line of input \n”;
getline(cin, line1, ‘?’);
c. cout << “Enter a line of input \n”;
getline(cin, line1) >> line2;
b) reads a line of input up to the first question mark. To select another stop-input character, replace the question mark.
Explanation: a) reads input up to the first newline, c) reads input into line1 up to the first newline, then puts all nonwhitespace from a second line of input into line2 . The reason this works is that getline returns a reference to cin which may be used with the extraction operator >> to extract another line into another variable.
You might also like to view...
Ethernet users on opposite sides of a bridge are in separate
a. internets b. intranets c. collision domains d. switches
The accompanying figure shows the working of a _____.
A. ?brute force attack B. ?denial of service attack C. ?quick attack D. ?phishing attack
Pointers are closely associated with array names.
Answer the following statement true (T) or false (F)
_____ is a system development process in which work activities - analysis, design, implementation - are repeated until the system is closer to what is ultimately needed.
a. Decomposition b. Iteration c. Multiplicity d. Reuse