How do I make a text document open in c++
I want the text document to open up at the end
Code
#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<vector>
#include<iomanip>
using namespace std;
int main(){
int i=0;
double sum=0;
string temp;
string line;
vector<string>nums;
ifstream myfile("S://Public/Davis/test.txt");
if(myfile.is_open()){
while(myfile.good()){
getline(myfile,line);
nums.push_back(line);
i++;
}
myfile.close();
}
else cout<<"Unable to open file";
for(int a=0;a<nums.size();a++){
for(int k=a;k<nums.size();k++){
if(nums[a]<nums[k]){
temp=nums[a];
nums[a]=nums[k];
nums[k]=temp;
}
}
}
int u=nums.size();
int temp1=atoi(nums[0].c_str());
int temp2=atoi(nums[u-1].c_str());
double x=2/(1/double (temp1)+1/double (temp2));
ofstream myfile2("H:\\Avg Output.txt");
if(myfile2.is_open()){
myfile2<<"Sorted Numbers: ";
for(int i=0;i<nums.size();i++){
if(i==nums.size()-1){
myfile2<<nums[i]<<endl;
}
else{
myfile2<<nums[i]<<", ";
}
}
myfile2<<"Harmonic Mean: "<<x<<endl;
myfile2.close();
}
else cout<<"Unable to open file";
cout<<"Done!";
return 0;
}![[Image: MOSHED-2019-11-30-10-59-36.jpg]](https://i.ibb.co/T2TX2xZ/MOSHED-2019-11-30-10-59-36.jpg)


