Given the following input buffer and buffer pointer starting point (1), after ea
ID: 3790178 • Letter: G
Question
Given the following input buffer and buffer pointer starting point (1), after each read operation, show what value will be stored, and where the buffer pointer will be pointing. R represents the ENTER character in the output buffer. Use a B to represent the BLANK character if necessary in the value stored.
Read operation Value stored after read Buffer pointer
a) cin __________ __________
b) getline __________ __________
c) cin __________ __________
d) getline __________ __________
e) getline __________ __________
1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 R c R d e a b f g h StartExplanation / Answer
--->cin function read the buffer till an null character is encountere or any delimiter is encounterd. and it stores the string eliminating the null charcter or delimiter. delimiter can be a new line character i.eR in given example
--->getline functions read the input untill a new line is encounterd
a)here the cin reads abB; since B indicates the space it stops reading and stores ab and eliminates B as it is delimiting character
b)here getline reads the R i.e new line character hence it stops reading next character and stores nothing
c)next cin reads cR and stops reading as the delimiting character occured and stores c, and eliminates R as it is delimiting character
d)getline reads deBfghiBR and stops reading as the new line character is encountered and stores deBfghi and eliminates r
e)getline reads R and stops reading as new line character is encountered and does not store anything.
-->The Buffer Pointer moves to next element of buffer as soon as the present element of buffer is read.
Read Operation value stored after Read Buffer Pointer a)cin ab 4 b)getline B 5 c)cin c 7 d)getline deBfghiB 16 e)getline B 17Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.