#include #include #include using namespace std; int main() { ifstream fin; fin.open ("flowers.dat", ios::in); //Declare variables here string flowerName; string sun_shade; // Open input file if (fin.is_open()) { // Write while loop that reads records from file. while ( fin>>flowerName>>sun_shade) { // Print flower name cout << flowerName << " grows in the " << sun_shade << endl; } } fin.close(); return 0; } // End of main function
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream fin;
fin.open ("flowers.dat", ios::in);
//Declare variables here
string flowerName;
string sun_shade;
// Open input file
if (fin.is_open())
{
// Write while loop that reads records from file.
while ( fin>>flowerName>>sun_shade)
{
// Print flower name
cout << flowerName << " grows in the " << sun_shade << endl;
}
}
fin.close();
return 0;
} // End of main function
------------------flowers.dat------------------
rose light
sunflower high
Sample Output

#include #include #include using namespace std; int main() { ifstream fin; fin.open ("flowers.dat", ios::in); //Declare variables...