Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Leda > #include <fstre...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 92 of 212
Post > Topic >>

#include <fstream> using Dev C++// how to specify a file location in windows xp

by moldylocks13@[EMAIL PROTECTED] (Flip) Jan 19, 2004 at 12:38 PM

im a beginer and i have a simple question. This code is an example
from my text book im trying to understand by changing it, and so far
i've been stuck at this level because i dont understand how it works.

this is a demonstration using <fstream> lib for file IO , and i dont
know the proper syntax for specifying an exact location on the HD that
i would want to save or open a file to.

in this example they are using a file called "infile.dat"..HOW can i
change this to be anything differant. I'm working on XP with Dev C++
...and lets say  i wanted to save or open a file from a location in MY
Do***ents, it would be something like this: C:\Do***ents and
Settings\endALL\My Do***ents\File Folder
.....ok, so i'll admit, i tried  using an addresse with backslashes
like that and was promptly reminded that that is used to tell the
compiler that im giving it an escape sequence..

so how can i tell the compiler (in a way that it will understand)
where i want it to save and open files from?

any information appreciated!

thanks

philip

**heres the code:

#include <stdlib.h>
#include <fstream>

int main()
{
     using namespace std;
     ifstream in_stream;
     ofstream out_stream;

     in_stream.open("infile.dat");
     if (in_stream.fail())
     {
        cout << "Input file opening failed.\n";
        exit(1);
     }

     out_stream.open("outfile.dat");
     if (out_stream.fail())
     {
     :
     :

      system("PAUSE");

return 0;
}
 




 3 Posts in Topic:
#include using Dev C++// how to specify a file locatio
moldylocks13@[EMAIL PROTE  2004-01-19 12:38:17 
Re: #include using Dev C++// how to specify a file loc
"sirclif" <c  2004-10-20 15:22:52 
Re: #include using Dev C++// how to specify a file loc
"sirclif" <c  2004-10-20 15:23:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Sep 4 23:53:28 CDT 2008.