File Loading/Saving Problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

File Loading/Saving Problem

Post by DarkWhoppy »

I started working on my own Load/Save functions last night. And run into one problem... when I try to save a "stringc" I get a bunch of errors.

Code: Select all

stringc PlayerName;

PlayerName = "Niko Gebhardt";

//open file blah blah blah
o_file <<PlayerName;

//then close the file blah blah
Looks like it should work eh? I'm using the <fstream> functions to open and close my files. Everything will save except for the PlayerName. Here's my error...

no match for `std::ofstream& << irr::core::stringc&' operator

Someone got a way around this?
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

use a char[256] instead of a stringc

Code: Select all

char[256] PlayerName; 

strcpy(PlayerName,"Niko Gebhardt"); 

//open file blah blah blah 
o_file << PlayerName; 

//then close the file blah blah 
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

I still get a load of errors. :( Thanks anyway
rt
Posts: 150
Joined: Sun Nov 30, 2003 6:54 am
Location: canada
Contact:

Post by rt »

DarkWhoppy wrote:I still get a load of errors. :( Thanks anyway
don't keep the errors to yourself.. share them with all of us 8) maybe we can help
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

ERRORS

player.h
declaration does not declare anything

player.h
parse error before `[' token

player.cpp
no match for `std::ofstream& << irr::core::stringc&' operator
Info Needed, which is inside the .H and .CPP files.

char[256] PlayerName;
strcpy(PlayerName,"Niko Gebhardt");

//--pieces taken from the SaveGame function.
ofstream o_file("save/game01.sav",ios::trunc);
o_file <<PlayerName;
o_file.close();
There're some of my errors... (the main ones, others just come up because of those... you know how C++ is =P )
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

rt wrote:use a char[256] instead of a stringc
You can also get a pointer to a C or C++ style char from a stringc if you like:

Code: Select all

stringc PlayerName; 
PlayerName = "DarkWhoppy"; 
o_file <<PlayerName.c_str(); 
Post Reply