1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Brilliant_brown [7]
4 years ago
12

What is the missing If condition in the following code fragment? The program is supposed to halt if the input file does not exis

t. ifstream inFile; inFile.open("myfile.dat"); if ( ) { cout << "Cannot open input file." << endl; return 1;
Computers and Technology
1 answer:
nikklg [1K]4 years ago
8 0

Answer:

The missing part is

if ( !inFile )

Explanation:

The full codes are as follows:

  1.    ifstream inFile;
  2.    inFile.open("myfile.dat");
  3.    if ( !inFile )
  4.    {
  5.        cout << "Cannot open input file." << endl;
  6.        return 1;
  7.    }
  8.    return 0;

Given that inFile is an ifstream object. When inFile is used to open "myfile.data", there will be possibility where myfile.dat is not available. If so, !inFile will be interpolated as true in the if condition and generate the message "Cannot open input file". This is one very simple way to check if the file exist when we try to read it from our program.

You might be interested in
8.9 Code Practice
jolli1 [7]

Answer: Here you go, change it however you like :)

Explanation:

v = [24, 20, 29, 32, 34, 29, 49, 46, 39, 23, 42, 24, 38]

usr = int(input("Enter number: "))

print(f"Index: {v.index(usr)}") if usr in v else print(-1)

5 0
3 years ago
Read 2 more answers
_______ technology is used in many hospitals to verify that the correct medication is being dispensed to the applicable patient.
Zepler [3.9K]
Barcode hospital operating suites, cardiac and intensive care units.
8 0
3 years ago
How do you take a picture underwater with my phone that is not waterproof?
LenaWriter [7]

Answer:

try putting it in a clear glass cup or sealing it tightly in a zip lock bag

Explanation:hope i helped love yall and can iget brainliest i only need two more

6 0
3 years ago
1.Write a program in python to find the sum and average of any 3 input numbers.
klasskru [66]

Answer:

ok then i might if i can be bothered

P(-2,2), Q(4,2), R(2, -6), S(-4,-6P(-2,2), Q(4,2), R(2, -6), S(-4,-6P(-2,2), Q(4,2), R(2, -6), S(-4,-6

4 0
3 years ago
An example of hardware is a(n) _____.
maks197457 [2]
An example of hardware would be a computer. it is a device used to hold and contain/operate software (programs) and exists in a real physical form.
7 0
4 years ago
Read 2 more answers
Other questions:
  • A virus is a name given to a small text file that's placed on your computer by the designers of the website when you visit that
    6·1 answer
  • The figure above shows two pith balls suspended by threads from a support. In the figure, A. the pith balls are uncharged. B. pi
    13·2 answers
  • After compiling source code, which command still needs to be run in order to copy the newly compiled binaries into a directory l
    5·1 answer
  • In the Remote Access Domain, if private data or confidential data is compromised remotely, you should set automatic blocking for
    15·1 answer
  • PROGRAM DESCRIPTION: In this assignment, you will write two complete C programs that will allow two players to play the game of
    12·1 answer
  • Software que busca, detecta y elimina malware tipo espía; puede instalarse en la computadora de manera aislada o en conjunto con
    11·1 answer
  • SOMEBODY HELP ME ASAP PLEASE AND THANK YOU
    14·2 answers
  • What are different between system and application software?​
    14·1 answer
  • FREEEEE 100 POINTS COME TAKE COME COME COME<br><br> only if u like da black panther
    8·2 answers
  • _____ is a system in which a finite set of words can be combined to generate an infinite number of sentences.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!