gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Beginner wondering something...

#158712 - 11X_daemon_X11 - Mon Jun 16, 2008 7:45 pm

Alright, I had someone help me with this, and I came up with this:

//Nds text writer
#include <iostream>
#include <fstream>
#include <string>

int main ( )
{
string filename;

cin >> filename;
filename += ".txt";

ofstream ndstxt(filename); // might need filename.c_str()

if (ndstxt)
{
string line;
while (getline(cin,line)) {
ndstxt << line;
}
ndstxt.close( ); // slightly superfulos, will get closed anyway.
}
else
{
cout<<"ERROR ABORT"
}

return 0;

}


Now, does this seem a little more logical to write a text file and allow player input?
_________________
IRC (please join :D):

http://evilnetirc.ath.cx/

#158724 - silent_code - Mon Jun 16, 2008 9:07 pm

What was the question? '8^|
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#158731 - 11X_daemon_X11 - Mon Jun 16, 2008 10:01 pm

is that all properly written and would it work properly? he said he saw a few things that he didn't think belonged (I can't remember), but wasn't sure if he should take them out when helping me with it.
_________________
IRC (please join :D):

http://evilnetirc.ath.cx/