Another C++ problem

Discuss any other topics here
Post Reply
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Another C++ problem

Post by LtForce » Sun Jun 03, 2007 8:28 pm

I've been making one program for weeks when suddenly I realised that I don't know how to scipt save fuction. Please, I desperatly need help!!
Lithuanians for Georgia!

User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR » Sun Jun 03, 2007 11:49 pm

Saving what, a file?

Code: Select all

#include <fstream>

ofstream file("filename.txt");

file << "Some text.\n";

file.close();
Last edited by AndyCR on Mon Jun 04, 2007 6:37 am, edited 1 time in total.

User avatar
psychopath
Posts: 32
Joined: Wed Jul 13, 2005 4:05 am
Location: Where circles begin.
Contact:

Post by psychopath » Mon Jun 04, 2007 3:02 am

Shouldn't that be ofstream?

User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR » Mon Jun 04, 2007 6:38 am

Thanks! :) Fixed.

User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Post by LtForce » Mon Jun 04, 2007 6:49 am

There are lots of EditBoxes(It's where you can write text or numbers). And it would be stupid to fill in those EditBoxes again and agina everytime I run the program. So isn't there pre-made button that does that. I want that when I fill these EditBoxes and close the program and run it again EditBoxes would be filled with same stuff I filled it last time I opened them
Lithuanians for Georgia!

User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Post by LtForce » Thu Aug 09, 2007 3:14 pm

AndyCR wrote:Saving what, a file?

Code: Select all

#include <fstream>

ofstream file("filename.txt");

file << "Some text.\n";

file.close();
I've started using VC++ Express edition now and I to use that thing that I've quated again. But where am I supposed to write #include <fstream>?
Lithuanians for Georgia!

User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Post by paradoxnj » Thu Aug 09, 2007 6:14 pm

The standard is at the top of your code file. The compiler allows you to put it anywhere though.

User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Another...

Post by LtForce » Wed Aug 29, 2007 10:54 am

I've just downloaded VC++ 2008 9.0 Beta and I'm using it now but I don't think scripting language has changed. So here's my new prob: I want this to happen: when I press button 1 new form(it's called 'Favorites') appears. How do I do that?

Code: Select all

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 Favorites::Activate()
		 }
There's an error in that 'Favorites::Activate()' line. So how should I do it? Must I include some files somewhere? Thanks in advance and if these questions are annoying just tell
Lithuanians for Georgia!

User avatar
AndyCR
Posts: 1449
Joined: Wed Jul 06, 2005 5:08 pm
Location: Colorado, USA
Contact:

Post by AndyCR » Wed Aug 29, 2007 8:14 pm

I'm not familiar with .NET, but you're missing a semicolon.

User avatar
paradoxnj
RF2 Dev Team
Posts: 1328
Joined: Wed Mar 01, 2006 7:37 pm
Location: Brick, NJ
Contact:

Post by paradoxnj » Wed Aug 29, 2007 10:55 pm

AndyCR is correct. When using C++ all statements must end with ;

Post Reply