On Tue, Feb 23, 2010 at 2:22 PM, Jimmy Johnson <[email protected]> wrote:
> Using visual studio 2008 express...
>
> I can not open a file; f.is_open() is false.
>
> ifstream f;
> int num_patches;
>
> f.open ("teapot.txt");
> if (f.is_open()) {
> while (! (f.eof())) {
Not related to your question, but using eof() here is almost certainly
not what you want.
> f >> num_patches;
You probably want something more akin to:
while ( (f >> num_patches) ){
// stuff ....
}
if (f.eof()){
// reached end of file
}else{
// some other error
}
See <http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.5>
> ...
>
> So where do I put the "teapot.txt" file? I have tried several directories.
The one where the .exe happens to be is usually where it's looking
when you don't supply a path.
--
PJH
http://shabbleland.myminicity.com/env
http://www.chavgangs.com/register.php?referer=9375