-
May 19th, 2011, 05:10 PM
#1
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
-
May 19th, 2011, 07:30 PM
#2
Re: How do I open a text file in notepad?
ShellExecute()?
Ah, and... Welcome to CodeGuru!
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
May 19th, 2011, 09:41 PM
#3
Re: How do I open a text file in notepad?
-
May 19th, 2011, 09:51 PM
#4
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;
}
Last edited by iiSoMeGuY 7x; May 19th, 2011 at 09:56 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|