Question
Additionally, the code pattern for opening the input file has been implemented: fin.open(flowers.dat);. Finally, the code pattern for using a while loop to read input
Additionally, the code pattern for opening the input file has been implemented: fin.open("flowers.dat");. Finally, the code pattern for using a while loop to read input from the file has been implemented: while (fin >> flowerName >> grown). With these modifications, the program should now be able to read input from the flowers.dat file and print the flower names and where they can be grown.
*******************Made Modifications and still have same error message... what else can we do?
#include
#include
#include
using namespace std;
int main()
{
// Declare variables here
string flowerName;
string grown;
// Open input file
ifstream fin
fin.Open("flowers.dat");
// Check if file was successfully opened
if (!fin)
{
cout
return 1;
}
// Read input from file
while (fin >> flowerName >> grown)
{
// Print flower name and where it can be grown
cout
}
// Close file
fin.close();
return 0;
} // End of main function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started