Mar 7, 2017 at 7:18am Mar 7, 2017 at 7:18am UTC
Please help in terms of Visual studio:
Need to read an infile, square the numbers within the infile, and outfile those numbers to a new document. I AM LOST!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
char fileName;
double number = 0;
cout << "Enter an input file name: " ;
cin >> fileName;
ifstream inFile;
ofstream outFile;
inFile.open("C:\\Users\\Josh\\Desktop\\numbers\\a.txt" );
outFile.open("C:\\Users\\Josh\\Desktop\\numbers\\squareroots.txt" );
inFile >> number;
while (inFile)
{
sqrt(number);
inFile >> number;
outFile << number;
}
inFile.close();
outFile.close();
return 0;
Last edited on Mar 7, 2017 at 7:19am Mar 7, 2017 at 7:19am UTC