Question

In: Computer Science

Which of the following statement will, move the file pointer to the third ‘r’ in the...

Which of the following statement will, move the file pointer to the third ‘r’ in the file show below. Assume the newline character is 1 byte. Select all that apply.

                With

                great

                power

                comes

                great

                responsibility

Answers:

                Spidey.seekg(-19L, ios:end);

                Spidey.seekg(‘r’, ios:beg);

                Spidey.seekg(24, ios:cur);

                Spidey.seekg(“r?r?r”, ios:beg);

Solutions

Expert Solution

Spidey.seekg(-19L, ios:end);

This statement will move the pointer to third 'r' in the file. -19 means go back from the ios::end. The length of the "responsibility" is 14. One byte for new line character and 3 for "eat" from second last great. total becomes 18. To move pointer to 'r', add one more. The total becomes 19 positions.

Spidey.seekg(‘r’, ios:beg);

Valid statement, but there is no overloaded seekg which takes character as input. What compiler does, it converts the 'r' to its equivalent ASCII value and move the pointer to that position from beginning.

Spidey.seekg(24, ios:cur);

Valid statement.

  1. With (4 + 1 for newline character)
  2. great ( 5 + 1)
  3. power (5 + 1)
  4. comes (5 + 1)
  5. great (5 + 1)
  6. responsibility (12)

Using above character count for each line, to move to third 'r', need to move pointer by:

5+ 6 + 6 + 6 + 1 (only g from great) = 24

Spidey.seekg(“r?r?r”, ios:beg);

Not a valid statement. C++ provided no overloaded function which takes string as first argument in seekg.


Related Solutions

Move the file “nfile2” into the “unix” directory. Copy the file “nfile1” into the “java” directory....
Move the file “nfile2” into the “unix” directory. Copy the file “nfile1” into the “java” directory. Show how you would create the files “test1”, “test2”, & “test3” in the “test” directory to ensure that they have the same file creation date/time. From the ~ folder, use the * and then the [ ] wildcard procedures to list all the files in the “test” directory. From the directory structure above, give an example of a relative path & an absolute path....
Create a data file frame in R called musseldata which has the following observations: species length...
Create a data file frame in R called musseldata which has the following observations: species length drywght tidehght calif     113    14.3     low tross      48     6.9     med calif      72     8.1     high calif      82     8.7     med tross      33     4.9     high tross      51     7.0     med calif      94   11.6     low Type the name of the data frame and copy/paste your R command the result into the green box. Use a logical condition with the subset() function to create a subset of the data called...
Which of the following is a true statement? Which of the following is a true statement?...
Which of the following is a true statement? Which of the following is a true statement? a. The electric potential energy depends on both the electric field and the amount of charge moving through that field. b. The electric potential depends on both the electric field and the amount of charge moving through that field. c. The electric potential energy and the electric potential depend on both the electric field and the amount of charge moving through that field. d....
Which of the following is a positive statement and which of the following is a normative statement?
Which of the following is a positive statement and which of the following is a normative statement?  Increasing the minimum wage increases the unemployment rate. The minimum wage should be increased. The number of tariffs ought to bel reduced. This country should seek to maximize the rate of employment above all other goals.
Please answer the problem below in C programming language: Create a pointer activity source file -...
Please answer the problem below in C programming language: Create a pointer activity source file - cptr2.c - that takes two arguments, a number from 1 to 3, and a string sentence(s). Create variables for a character, an integer, a string pointer. Based on integer value you will use that number of string pointers. The string variable is a string pointer that has not been allocated.    Define pointers to those variables types without any initialization of those points to the...
Stet by step in R and attach R file and R codes too - Thanks Use...
Stet by step in R and attach R file and R codes too - Thanks Use one of the real-world example data sets from R (not previously used in the R practice assignment) or a dataset you have found, and at least two of the tests and R functions covered in the practice assignment to conduct a hypothesis test then report your findings and give proper conclusion(s). Use the following supporting materials for R syntax, data sets and tools, along...
Which of the following files is a temporary file? a. transaction file b. master file c. reference file d. none of the above
Which of the following files is a temporary file? a. transaction fileb. master filec. reference filed. none of the above
Given the following file : -rw-r--r-- 1 malsaid faculty 74 Oct 20 16:50 a What will...
Given the following file : -rw-r--r-- 1 malsaid faculty 74 Oct 20 16:50 a What will be the file permissions after the following command: chmod ou+x,g+w,o-r a
A cell is LEAST likely to require a transport protein to move which of the following...
A cell is LEAST likely to require a transport protein to move which of the following molecules across its membrane?: (A) Sucrose (B) Hydrogen ions (C) Carbon dioxide (D) Chloride ions
Download the file data.csv (comma separated text file) and read the data into R using the...
Download the file data.csv (comma separated text file) and read the data into R using the function read.csv(). Your data set consists of 100 measurements in Celsius of body temperatures from women and men. Use the function t.test() to answer the following questions. Do not assume that the variances are equal. Denote the mean body temperature of females and males by μFμF and μMμMrespectively. (a) Find the p-value for the test H0:μF=μMH0:μF=μM versus HA:μF≠μM.HA:μF≠μM. Answer (b) Are the body temperatures...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT