December 26th, 2012, 07:04 PM
Opening Documents with C++
OK. This is my first post on this site, and I consider myself quite a beginner in C++. I want to know how to open up a
document using C++. Ive tried many times, but it just comes up with a blank console which goes away when I press
enter. I suspect the problem is that I am making a cionsole application instead of some other application that I sgould be using. (I am using Miscrosoft Visual C++ 2010) I really do not know why this is not working. Is it because I am
trying to open a document that is not allowed to be opened???? (Im an adminstator on my computer so that is
proobably not it.) Anyway here is the code that I wrote:
using namespace std;
wordDocument.open("C:\\Users\\Haziqu\\Documents\\STUDYING STUFF\\BUSINESS\\adding value #1.txt.txt");
December 26th, 2012, 10:54 PM
Re: Opening Documents with C++
The program does that because that is what you wrote.
Originally Posted by Hazique35
All your program does is
1) open a new output file (the wordDocument.open() function),
2) wait for a key to be pressed using the cin.get()
3) returns 0 from main(), ending the program.
What else did you expect the program to do? If you wanted to open an existing file for input, then the class to use is ifstream, not ofstream. Otherwise, the program is behaving exactly as you wrote it.
Last edited by Paul McKenzie; December 26th, 2012 at 10:57 PM.
Click Here to Expand Forum to Full Width