Comp Sci Where to save .dat file for C++ programming

AI Thread Summary
In C++ programming, when working with file streams, it's essential to know where to save your .dat files. You can create a .dat file directly in your code using ifstream in_stream.open("name.dat"), which will generate the file if it doesn't exist. However, for project requirements, you must have a pre-made input file and know its location. The default directory for saving and accessing files is typically the same as where the program is executed. Understanding these file management aspects is crucial for successful project completion.
mathnoobie
Messages
62
Reaction score
0

Homework Statement


I'm starting my C++ project which requires me to call a file stream and output the data to four other output streams.
Before I start, I want to know if I need to have a .dat file premade and saved somewhere so I can call it or do I just make that file in my code by using ifstream in_stream.open("name.dat");
 
Physics news on Phys.org
If you open a file that does not exist, it will be made.
 
Yes. But I am required to turn in an input file and many output files, I wouldn't even know where those would be saved if I don't know where to save my input file.
 
The default place for saving the file (and accessing files) is in the same directory in which the program is executing.
 
Thank you!
 

Similar threads

Replies
15
Views
3K
Replies
23
Views
8K
Replies
3
Views
3K
Replies
2
Views
2K
Replies
2
Views
4K
Replies
1
Views
2K
Back
Top