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 »

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 »

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 »

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 »

Thanks! :) Fixed.
User avatar
LtForce
Posts: 437
Joined: Wed May 03, 2006 11:15 am
Location: Vilnius, Lithuania

Post by LtForce »

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 »

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 »

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 »

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 »

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 »

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