Write a program that prompts for an input file name, receives the input file name in a C-string. The program should check for errors opening a file. It is not necessary for the program to do anything other than open the file.

What will be an ideal response?


```
#include
#include //unnecessary, fstream gets this
#include //for exit(int)
int main()
{
using std::ifstream;
using std::cout;
using std::cin;

char name[16];
cout << "enter a file name, 15 characters max:\n";
cin >> name;
ifstream inStream;
inStream.open(name);
if (inStream.fail())
{
cout << "Opening file " << name <<" failed\n";
exit(1);
}
// code that uses the file
```

Computer Science & Information Technology

You might also like to view...

Which of the following is most likely a base class of the other three?

a. automobile. b. convertible. c. miniVan. d. sedan.

Computer Science & Information Technology

In an RGB file, whenever the three components are the same, the pixel will have no color and can be only a neutral gray.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The CSS specifications are overseen by the ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The ____ form property contains the mailto address where the form results will be emailed or the URL to the dynamic page/script that will process the form.

A. Class B. Mailto C. Action D. MIME

Computer Science & Information Technology