How do I open a text file in notepad?
I have a program that saves the date and time into a variable and then builds a text file with that variable as the name.
I want to open that text file in notepad from the same program right before the program closes.
So basically i want to open a text file in notepad using a variable to designate the file name.
Mike
Re: How do I open a text file in notepad?
ShellExecute()?
Ah, and... Welcome to CodeGuru! :)
Re: How do I open a text file in notepad?
Re: How do I open a text file in notepad?
Create File:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream outputFile;
char fileName[48];
cout << "Enter File Name: ";
cin.getline(fileName, 48); //make sure to add the .txt
outputFile.open(fileName);
outputFile << ; //send stuff here
//repeat as necessary...
outputFile.close();
return 0;
}
Read File:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile;
char fileName[48];
cout << "Enter File Name: ";
cin.getline(fileName, 48); //make sure to add the .txt
inFile.open(fileName);
inFile >> ; //read variables and stuff here
//repeat as necessary...
inFile.close();
return 0;
}