Study Guide Help?

Hey guys I have a test in one of my computer science courses this week and have been given a study guide to help review. I have filled about half of this review but, have encountered some questions that I can't 'surely' answer myself. If anyone would take the supply an answer for any of these that would be great! I want to try to fill this entire sheet out so I can study it throughout the rest of the week.

1.Give a detailed description of C++ compilation. Provide each step and the name of each program used in the process of compilation.

6. When writing a function header/prototype that takes a mulidimensional array as an argument, how many dimensions must the user supply?

8. Arrays cannot have a variable (non constant) size in declaration. Why?

14. What are the ways to check that a stream is or is not in a failstate? Discuss the difference in these methods, and how could the choice of method affect the behavior your program?

16. When using extraction to pull from a stream, where does the read stop and where is the buffer pointer left after the read?

17. When using getline to pull from a stream, where does the read stop and where is the buffer pointer left after the read?

18. When intermixing extraction and getline to read from a stream, which arrangement will cause errors? Why is this?

19. What can be done in order to avoid the error in the previous question? Name at least two methods to avoid this issue.

22. When opening a file, what must be done to a string containing a file name?

23. If an ifstream tries to open a file that doesn’t exist, what happens?

24. If an ofstream tries to open a file that doesn’t exist, what happens?

-------------------------------------------------------------------------------

Some Questions that I answered and am on the fence about.

Are arrays stored contiguously within memory? --> I answer yes.

What is a consequence of forgetting to close an output file before exiting the program? --> I answer: Whatever is still in the buffer may not be written out.

-------------------------------------------------------------------------------

Thank you to anyone whom takes the time to answer any of these for me!
23, 24:
http://en.cppreference.com/w/cpp/io/basic_ifstream/open
http://en.cppreference.com/w/cpp/io/basic_ofstream/open
Look at what it effectively calls and look on corresponding entry here: http://en.cppreference.com/w/cpp/io/basic_filebuf/open

22: In modern C++ nothing. Do not know if you are learning modern or old C++.

18, 19: http://stackoverflow.com/questions/21567291/why-does-stdgetline-skip-input-after-a-formatted-extraction
Additionally all which will normally lead to error in either case.

17: http://en.cppreference.com/w/cpp/string/basic_string/getline
Read on its behavior in different cases.

16: It ends as soon as it encounters a character not part of value. Usually whitespace (tab, newline..), but in case of "123abc", when reads int, it will extract 123 and leave abc in buffer. This is not an error.

14: Check iostate flags manually, use accessor functions, convert to bool. Look here at the very end:
http://en.cppreference.com/w/cpp/io/ios_base/iostate

8: Because Standard says so.

6: All, bar first one.

1: http://lmgtfy.com/?q=C%2B%2B+compilation+process

----
are arrays...: you are correct
What is consequence...: You are correct. Additionally it is unknown what happens to files themselves and how OS handles this. In theory their descriptor might never be closed and the will become inaccessible until system restart.
Topic archived. No new replies allowed.