I get this odd compile error:
21 C:\programs\testspil\testspil.cpp `noreplace' is not a member of type `
help appreciatedCode:line 21: ofstream a_file("wins.txt", ios::noreplace);
I get this odd compile error:
21 C:\programs\testspil\testspil.cpp `noreplace' is not a member of type `
help appreciatedCode:line 21: ofstream a_file("wins.txt", ios::noreplace);
>I get this odd compile error
It's hardly odd at all. noreplace is not standard C++, so you're probably using a compiler that doesn't support it. Think about why you're trying to use noreplace and see if you really need it. Chances are that you don't.
My best code is written with the delete key.
how else would you check if the file is already there? It's a statistics file where I want to store int's... So if it's the first time running the program then it should create a statistics file, but if it's already there I don't want to trunctate it...
So use ios::app then. Have a look at this page for the different flags.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
>how else would you check if the file is already there?
Use something nonportable and implementation-dependent that we can't describe because you haven't give us any more detail about your compiler. Or you could simply open the file for reading. If the open is successful then the file exists, if it fails you'll simply have to assume it did so because the file doesn't yet exist.
>but if it's already there I don't want to trunctate it...
See? You didn't really need noreplace after all, just use ios_base::app.
My best code is written with the delete key.
Is it recommended to use ios::app or ios_base::app?
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
>Is it recommended to use ios::app or ios_base::app?
ios_base::app is recommended simply because the C++ standard makes no mention of ios::app being valid that I can remember.
My best code is written with the delete key.
That's a good enough reason for me then.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
If you don't mind, I'll correct myself before someone else does. After looking at the standard, both are valid. ios_base is where the openmode app is defined, but ios is a typedef defined asOriginally Posted by Prelude
Where basic_ios is a template class derived from ios_base. So both will work, both are standard, and which you use looks to be a matter of style.Code:typedef basic_ios<char> ios;
My best code is written with the delete key.
Gah! Prelude was wrong! The world's going to heck in a handbasket!
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
Not wrong, just not completely correct
Last edited by Thantos; 06-05-2004 at 10:32 PM.
>Not wrong, just completely correct
I'm guessing you missed a 'not' in there.
Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah
You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie
I use Bloodshed Dev-C++
thx for the help, but...
in line 25 below:
is there a voide value that isn't ignored?Code:23 ifstream winfilein; 24 25 if(!(winfilein.open("wins.txt", ifstream::in))) 26 { 27 winfilein.close(); 28 blahblah; 29 }
I've looked up the function, but it seemed perfectly fine...
Is it because of the IF statement?
It is perfectly fine.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law