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
#include
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...
A parameter query prompts you for the criteria before running the query
Indicate whether the statement is true or false
Computer Science & Information Technology
Which of the following is NOT a commercially available type of ERP software?
A. Microsoft B. Oracle C. PeopleSoft D. SAP
Computer Science & Information Technology