Question: This code is not working on my updated visual studio C++: #include using namespace std; int main() { string filename = Data3.txt; string line; ifstream

This code is not working on my updated visual studio C++:

#include using namespace std; int main() { string filename = "Data3.txt"; string line; ifstream myfile (filename.c_str()); ofstream myoutfile ("Volume.txt"); if (myfile.is_open()) { vector< int > tokens; while ( getline (myfile,line) ) { string buf; // Have a buffer string stringstream ss(line); // Insert the string into a stream // Create vector to hold our words while (ss >> buf) { tokens.push_back(atoi(buf.c_str())); } } myfile.close(); myoutfile << "Number" << "\t\t\t" << "volume" << "\t\t\t" << "radius" << "\t\t" << "Property" << endl; for (int i = 1; i < tokens.size(); ++i) { float r = float(tokens[i])/100.0; float volume = (4.0/3.0)*3.14*r*r*r; if(volume > 1.25 ) { myoutfile << i<< setprecision(2) << "\t\t\t" << volume<< "\t\t\t" << r << "\t\t" << "Large" << endl; } else { myoutfile << i << setprecision(2)<< "\t\t\t" << volume << "\t\t\t"<< r << "\t\t" << "Small" << endl; } } myoutfile.close(); } else { cout << "Unable to open file" << endl; exit(1); }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!