Where to save .dat file for C++ programming

Click For Summary

Discussion Overview

The discussion revolves around the handling of .dat files in a C++ programming project, specifically regarding the necessity of pre-existing files and their storage locations. It addresses both theoretical and practical aspects of file input/output operations in C++.

Discussion Character

  • Homework-related
  • Technical explanation

Main Points Raised

  • One participant inquires whether a .dat file needs to be created beforehand or if it can be generated within the code using ifstream.
  • Another participant asserts that opening a non-existent file will result in its creation.
  • A third participant expresses concern about the requirement to submit specific input and output files, questioning where these files would be saved without prior knowledge of the input file's location.
  • It is mentioned that the default location for saving and accessing files is typically the same directory where the program is executed.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the necessity of a pre-made .dat file, and there are differing views on file management practices in C++. The discussion remains unresolved regarding the best approach to file handling in this context.

Contextual Notes

There are limitations regarding assumptions about file paths and the execution environment, which may affect how files are accessed and saved.

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 ·
Replies
15
Views
3K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 23 ·
Replies
23
Views
9K
Replies
1
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
2K