Click here to Skip to main content
15,904,024 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Menu DrawItem issue when Windows 7 workstation is locked. Pin
Maxwell Chen3-Feb-10 21:38
Maxwell Chen3-Feb-10 21:38 
QuestionOracle connection Pin
MsmVc3-Feb-10 18:05
MsmVc3-Feb-10 18:05 
AnswerRe: Oracle connection Pin
«_Superman_»3-Feb-10 18:11
professional«_Superman_»3-Feb-10 18:11 
GeneralRe: Oracle connection Pin
MsmVc3-Feb-10 18:19
MsmVc3-Feb-10 18:19 
GeneralRe: Oracle connection Pin
Garth J Lancaster3-Feb-10 22:20
professionalGarth J Lancaster3-Feb-10 22:20 
QuestionProfiling Code in Studio 2008 HEre is a Wnderful REsource Pin
MicroImaging3-Feb-10 9:53
MicroImaging3-Feb-10 9:53 
Questionnewbie cryptography question Pin
fordsport3-Feb-10 8:59
fordsport3-Feb-10 8:59 
AnswerRe: newbie cryptography question Pin
KingsGambit3-Feb-10 20:25
KingsGambit3-Feb-10 20:25 
GeneralRe: newbie cryptography question Pin
fordsport4-Feb-10 3:22
fordsport4-Feb-10 3:22 
QuestionURL Monitor Pin
Member 68648393-Feb-10 7:38
Member 68648393-Feb-10 7:38 
QuestionRe: URL Monitor Pin
CPallini3-Feb-10 9:04
mveCPallini3-Feb-10 9:04 
AnswerRe: URL Monitor Pin
Member 68648393-Feb-10 9:15
Member 68648393-Feb-10 9:15 
GeneralRe: URL Monitor Pin
CPallini3-Feb-10 20:56
mveCPallini3-Feb-10 20:56 
QuestionHow to get disk/drive size Pin
MKC0023-Feb-10 2:28
MKC0023-Feb-10 2:28 
AnswerRe: How to get disk/drive size Pin
Richard MacCutchan3-Feb-10 2:51
mveRichard MacCutchan3-Feb-10 2:51 
GeneralRe: How to get disk/drive size Pin
Adam Roderick J3-Feb-10 19:14
Adam Roderick J3-Feb-10 19:14 
GeneralRe: How to get disk/drive size Pin
MKC0023-Feb-10 20:20
MKC0023-Feb-10 20:20 
GeneralRe: How to get disk/drive size Pin
Richard MacCutchan3-Feb-10 22:02
mveRichard MacCutchan3-Feb-10 22:02 
AnswerRe: How to get disk/drive size Pin
Kushagra Tiwari3-Feb-10 2:57
Kushagra Tiwari3-Feb-10 2:57 
GeneralRe: How to get disk/drive size Pin
MKC0023-Feb-10 20:19
MKC0023-Feb-10 20:19 
QuestionWriting Objects into files in binary mode Pin
Sujan Dhakal3-Feb-10 1:58
Sujan Dhakal3-Feb-10 1:58 
AnswerRe: Writing Objects into files in binary mode Pin
Cedric Moonen3-Feb-10 2:10
Cedric Moonen3-Feb-10 2:10 
GeneralRe: Writing Objects into files in binary mode Pin
Sujan Dhakal3-Feb-10 2:17
Sujan Dhakal3-Feb-10 2:17 
AnswerRe: Writing Objects into files in binary mode Pin
CPallini3-Feb-10 2:20
mveCPallini3-Feb-10 2:20 
GeneralRe: Writing Objects into files in binary mode Pin
Sujan Dhakal3-Feb-10 2:28
Sujan Dhakal3-Feb-10 2:28 
so it was only the issue of std::string class, thanks i succeed with the following code.

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

class Data
{
public:
	char name[20];
	int id;
public:
	Data(){}
	Data(char *n,int id){strcpy(name,n);this->id=id;}
};

int main() {

	Data objdata;
	//fstream file("c:\\test.txt",ios::out | ios::binary);
	fstream file("c:\\test.txt",ios::in | ios::binary);
	if(file.is_open())
	{
		//file.write((char*)&objdata,sizeof(Data));

		file.read((char*)&objdata,sizeof(Data));
		cout<<objdata.name<<objdata.id;
		cout<<"Success";
		file.close();
	}
	else
	{
		cout<<"Error";
	}

	return 0;
}

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.