Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:06
Larsson12-Oct-06 11:06 
GeneralRe: Dialog problem! Pin
Hamid_RT12-Oct-06 19:49
Hamid_RT12-Oct-06 19:49 
AnswerRe: Dialog problem! Pin
amjadamq12-Oct-06 10:46
amjadamq12-Oct-06 10:46 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:07
Larsson12-Oct-06 11:07 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:12
Larsson12-Oct-06 11:12 
GeneralRe: Dialog problem! Pin
prasad_som12-Oct-06 19:07
prasad_som12-Oct-06 19:07 
GeneralRe: Dialog problem! Pin
David Crow13-Oct-06 2:46
David Crow13-Oct-06 2:46 
Questionofstream issue in a class Pin
Nick Usechak12-Oct-06 10:17
Nick Usechak12-Oct-06 10:17 
Could someone please tell me where I've gone wrong with the following class? The following code compiles and runs with no errors (VC++.Net 1.1) but the data is not written to the file (or at least not properly). Ideally I would like a class that opens up a stream for intermittent writing from a main program via multiple member functions and then closes the stream when the class destructor is called. I figure that that should be a trivial thing to do.

Thank you in advance for any help and I apologize if this turns out to be a stupid mistake on my part.

Nick
<pre>
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;

class plot_interface{
private:
ofstream outFile;
public:
bool data_write(char *FileName);
plot_interface(){PlotType = 0;};
int PlotType;
};
bool plot_interface::data_write(char *FileName){
//ofstream outFile; // if this is uncommented the program works corectly
// but it does not achive what I want it to.
outFile.open(FileName,ios::out | ios::binary);
outFile.write((char *) &PlotType, sizeof(int));
return true;
}


void _tmain(int argc, _TCHAR* argv[]){
plot_interface plot;
plot.PlotType = 32;
if(!plot.data_write("loser.dat")){cout<<"could not open the file"; return;}

int temp_type;
ifstream inFile;
inFile.open("loser.dat");
inFile.read((char *) &temp_type, sizeof(int));
cout<<"we read: "<<temp_type<<" back from the file\n\n";

cin.get();
return;
}

</pre>
AnswerRe: ofstream issue in a class Pin
Christian Graus12-Oct-06 10:20
protectorChristian Graus12-Oct-06 10:20 
GeneralRe: ofstream issue in a class Pin
Nick Usechak12-Oct-06 10:27
Nick Usechak12-Oct-06 10:27 
AnswerRe: ofstream issue in a class Pin
Zac Howland12-Oct-06 10:31
Zac Howland12-Oct-06 10:31 
GeneralRe: ofstream issue in a class Pin
Nick Usechak12-Oct-06 10:50
Nick Usechak12-Oct-06 10:50 
GeneralRe: ofstream issue in a class Pin
Zac Howland12-Oct-06 11:33
Zac Howland12-Oct-06 11:33 
AnswerRe: ofstream issue in a class Pin
David Crow12-Oct-06 10:37
David Crow12-Oct-06 10:37 
GeneralRe: ofstream issue in a class Pin
Nick Usechak12-Oct-06 11:02
Nick Usechak12-Oct-06 11:02 
QuestionIf I may be so bold , newbie help [modified] Pin
hotari12-Oct-06 9:53
hotari12-Oct-06 9:53 
AnswerRe: If I may be so bold , newbie help Pin
Christian Graus12-Oct-06 10:06
protectorChristian Graus12-Oct-06 10:06 
GeneralRe: If I may be so bold , newbie help Pin
hotari12-Oct-06 10:44
hotari12-Oct-06 10:44 
GeneralRe: If I may be so bold , newbie help Pin
Christian Graus12-Oct-06 13:01
protectorChristian Graus12-Oct-06 13:01 
AnswerRe: If I may be so bold , newbie help Pin
Mark Salsbery12-Oct-06 10:07
Mark Salsbery12-Oct-06 10:07 
GeneralRe: If I may be so bold , newbie help Pin
hotari12-Oct-06 10:34
hotari12-Oct-06 10:34 
GeneralRe: If I may be so bold , newbie help Pin
Mark Salsbery12-Oct-06 10:41
Mark Salsbery12-Oct-06 10:41 
GeneralRe: If I may be so bold , newbie help Pin
hotari12-Oct-06 10:48
hotari12-Oct-06 10:48 
GeneralRe: If I may be so bold , newbie help Pin
Mark Salsbery12-Oct-06 11:07
Mark Salsbery12-Oct-06 11:07 
GeneralRe: If I may be so bold , newbie help Pin
hotari12-Oct-06 11:14
hotari12-Oct-06 11:14 

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.