English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

C++: if i have to open a file using C++ then i declare
ifstream fin("input.txt");
how can i be sure that the program knows where the file is?
anyway i can test it(if the file is opened)?

2006-10-07 07:48:21 · 5 answers · asked by jcol 2 in Computers & Internet Programming & Design

5 answers

it has to be in the same directory as the program

2006-10-07 07:52:04 · answer #1 · answered by VzjrZ 5 · 0 0

To be certain that the program knows where the file is, give it's location not just the file name. In other words:
"c:\input.txt" on windows or "/user/myhome/input.txt" on Unix or Linux.

2006-10-07 07:53:59 · answer #2 · answered by DadOnline 6 · 0 0

possibly best to fully qualify the file - so instead of "input.txt" you would put something like "C:/my_directory/input.txt" - that way you know it's exactly where you think it is...

2006-10-07 07:52:13 · answer #3 · answered by sean6045 2 · 0 0

Dont forget to use double backslash in C
"C:\\input.txt"

2006-10-07 07:59:05 · answer #4 · answered by Chri R 4 · 0 0

look at the program's menu for settings and find folders(default). default directories might be defined somewhere in the settings!

2006-10-07 07:56:43 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers