Click here to Skip to main content
15,915,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 14:47
Ambit23-Mar-03 14:47 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Stefan Pedersen23-Mar-03 23:36
Stefan Pedersen23-Mar-03 23:36 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
Dave Bryant23-Mar-03 13:52
Dave Bryant23-Mar-03 13:52 
GeneralRe: Emulating Win32 on Windows 98/Me? Pin
Ambit23-Mar-03 14:32
Ambit23-Mar-03 14:32 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
Navin23-Mar-03 16:42
Navin23-Mar-03 16:42 
AnswerRe: Emulating Win32 on Windows 98/Me? Pin
r i s h a b h s23-Mar-03 19:20
r i s h a b h s23-Mar-03 19:20 
GeneralTrying to create context-sensitive help with VC++ Pin
trimtrom23-Mar-03 11:53
trimtrom23-Mar-03 11:53 
GeneralAnnoying fstream problem!! Pin
Rickard Andersson2023-Mar-03 10:29
Rickard Andersson2023-Mar-03 10:29 
I have derived a class from fstream and my problem is that I can't write after I've read from the file.

My class looks like this:

class CLogBook : public fstream
{
public:
	CLogBook();
	~CLogBook() { close(); };

	void SaveLogData();
	void ReadLogData(string&);

	int& ErrorCode() { return m_errorCode; };
	string& ErrorMessage() { return m_errorMessage; };
	string& Extra() { return m_extra; };
	
private:
	string m_errorMessage;
	int m_errorCode;
	string m_extra;
};


SaveLogData() just formats a string and calls write(...).
ReadLogData look like this:

void CLogBook::ReadLogData(string& data)
{
	data.clear();
	seekg(0);
	while(!eof())
	{
		char* temp = new char[1024]; 
		getline(temp, 1024, '\n');
		data.append(temp);
		data.append("\n");
		delete [] temp;
	}
}


and my test code looks like this:

CLogBook dummy;
dummy.open("test.txt", ios_base::in | ios_base::out | ios_base::app);

dummy.ErrorCode() = 123;
dummy.ErrorMessage() = "Error occured in your brain.. please RTFM!";
dummy.Extra() = "WinMain";

dummy.SaveLogData(); // write
	
string buf("");
dummy.ReadLogData(buf);

MessageBox(NULL, buf.c_str(), "", MB_OK);

// this will not be written to the file! :(
dummy.ErrorCode() = 666;
dummy.ErrorMessage() = "never written words";
dummy.Extra() = "BASIC SUCKS";


I hope I've got everything here... hope you can help!

Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!

UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!

GeneralRe: Annoying fstream problem!! Pin
Christian Graus23-Mar-03 10:34
protectorChristian Graus23-Mar-03 10:34 
GeneralRe: Annoying fstream problem!! Pin
Rickard Andersson2023-Mar-03 10:56
Rickard Andersson2023-Mar-03 10:56 
GeneralRe: Annoying fstream problem!! Pin
Joaquín M López Muñoz23-Mar-03 11:00
Joaquín M López Muñoz23-Mar-03 11:00 
GeneralRe: Annoying fstream problem!! Pin
Rickard Andersson2023-Mar-03 11:12
Rickard Andersson2023-Mar-03 11:12 
GeneralRe: Annoying fstream problem!! Pin
Joaquín M López Muñoz23-Mar-03 20:13
Joaquín M López Muñoz23-Mar-03 20:13 
GeneralRe: Annoying fstream problem!! Pin
Rickard Andersson2023-Mar-03 22:36
Rickard Andersson2023-Mar-03 22:36 
QuestionMenu Mnemonics on Dialog? Pin
MKlucher23-Mar-03 10:05
MKlucher23-Mar-03 10:05 
AnswerRe: Menu Mnemonics on Dialog? Pin
Dave Bryant23-Mar-03 10:46
Dave Bryant23-Mar-03 10:46 
GeneralRe: Menu Mnemonics on Dialog? Pin
MKlucher24-Mar-03 5:36
MKlucher24-Mar-03 5:36 
GeneralDate Sorting Pin
Anthony988723-Mar-03 9:16
Anthony988723-Mar-03 9:16 
GeneralRe: Date Sorting Pin
Ted Ferenc23-Mar-03 12:20
Ted Ferenc23-Mar-03 12:20 
GeneralKeyboard Shortcuts for VC++ 6 Pin
MKlucher23-Mar-03 9:08
MKlucher23-Mar-03 9:08 
GeneralRe: Keyboard Shortcuts for VC++ 6 Pin
jmkhael23-Mar-03 9:11
jmkhael23-Mar-03 9:11 
GeneralHelp concering CDialogBar Pin
Steven M Hunt23-Mar-03 8:51
Steven M Hunt23-Mar-03 8:51 
GeneralRe: Help concering CDialogBar Pin
Rage23-Mar-03 21:06
professionalRage23-Mar-03 21:06 
GeneralRe: Help concering CDialogBar Pin
Steven M Hunt24-Mar-03 6:26
Steven M Hunt24-Mar-03 6:26 
QuestionHow do I completely clear a text file for re-use?? Pin
Anonymous23-Mar-03 7:27
Anonymous23-Mar-03 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.