|
From: rchavez <rc...@so...> - 2002-06-10 01:58:36
|
Nancy asks:
>
> Hi alls
>
>
> I have read a list of pair of dates (x,fx) from a file and work with these..
> My program don´t found this file and no display the message
> ^File no found" . I don´t know what is happening. Does somebody have one
> answer?
> .
I ran into a similar problem using files. In my case I didn't know that
DevC++ does not default to the directory where the executable file is stored
so my files were not found.
One fix was to explicitly set the directory path along with the file name.
For example, if you wanted the file prova2.dat to be read out of the
directory Dev-C++/datafiles on a PC use
"C:/Dev-C++/datafiles/prova2.dat" in f_in.open().
In microsoft operating systems the directory path is specified with '\' but
your code will be more portable if you use forward slash '/' instead.
There is probably a way to set the default directory path in your program
and there is also a way to specify the directory where the executable code
is stored but I don't know how. Can someone else help with this?
Rob
>
> int main();
> .
> [ifstream f_in;
> ..
> ..
> f_in.open("prova2.dat");
>
> if(f_in==NULL)
> {
> cout<<" Arquivo não encontrado";
> }
>
> f_in>> x >> fx;
> cout << x << fx;
>
>
>
> f_in.close();
>
> system("PAUSE");
> return 0;
> }
|