Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: classes and inline functions Pin
David Crow14-Mar-08 6:03
David Crow14-Mar-08 6:03 
QuestionBitmap button Pin
Schehaider_Aymen1-Dec-07 2:34
Schehaider_Aymen1-Dec-07 2:34 
AnswerRe: Bitmap button Pin
Hamid_RT1-Dec-07 3:14
Hamid_RT1-Dec-07 3:14 
GeneralRe: Bitmap button Pin
Schehaider_Aymen1-Dec-07 3:18
Schehaider_Aymen1-Dec-07 3:18 
GeneralRe: Bitmap button Pin
Schehaider_Aymen1-Dec-07 3:23
Schehaider_Aymen1-Dec-07 3:23 
GeneralRe: Bitmap button Pin
Hamid_RT1-Dec-07 4:44
Hamid_RT1-Dec-07 4:44 
QuestionProblem in capturing the enter event of an edit control. Pin
chandu0041-Dec-07 0:50
chandu0041-Dec-07 0:50 
AnswerRe: Problem in capturing the enter event of an edit control. Pin
Jijo.Raj2-Dec-07 0:59
Jijo.Raj2-Dec-07 0:59 
QuestionNo CPen? Pin
Haakon S.1-Dec-07 0:29
Haakon S.1-Dec-07 0:29 
AnswerRe: No CPen? Pin
CPallini1-Dec-07 0:44
mveCPallini1-Dec-07 0:44 
GeneralRe: No CPen? Pin
Haakon S.1-Dec-07 0:56
Haakon S.1-Dec-07 0:56 
GeneralRe: No CPen? Pin
Haakon S.1-Dec-07 1:38
Haakon S.1-Dec-07 1:38 
QuestionThreads Pin
krishna Vuppala30-Nov-07 23:30
krishna Vuppala30-Nov-07 23:30 
AnswerRe: Threads Pin
CPallini1-Dec-07 0:00
mveCPallini1-Dec-07 0:00 
GeneralRe: Threads Pin
krishna Vuppala1-Dec-07 0:46
krishna Vuppala1-Dec-07 0:46 
GeneralRe: Threads Pin
CPallini1-Dec-07 6:55
mveCPallini1-Dec-07 6:55 
GeneralRe: Threads Pin
Hamid_RT1-Dec-07 8:08
Hamid_RT1-Dec-07 8:08 
Questionabout unary_function Pin
George_George30-Nov-07 22:52
George_George30-Nov-07 22:52 
AnswerRe: about unary_function Pin
CPallini1-Dec-07 0:43
mveCPallini1-Dec-07 0:43 
Questioni have some question about binary stream file. Pin
buffering8330-Nov-07 22:07
buffering8330-Nov-07 22:07 
first, sorry my english is a little^^;
i type a cod about binary search.

first, i make Video class.
and i want video class to save some andy txt file.
this is my code.
i think ,
there is some problem at write method.
but i don't know why it is happened....
please give me your advice~


#include<iostream>
#include <string>
#include <fstream>

using namespace std;

class Video
{
private:
char *name;
int number;

public:
// ifstream fin;
// ofstream fout;
Video()
{
name = new char[30];
strcpy(name , "nothing");
number = 0;
}

Video(char *imsi_name, int imsi_number)
{
name = new char[strlen(imsi_name)+1];
strcpy(name, imsi_name);
number = imsi_number;
}

int Get_number()
{
return number;
}
char *Get_name()
{
return name;

}

void Set_number(int k)
{
number = k;
}

void Set_name(char *imsi)
{
delete[] name;
name = new char[strlen(imsi)+1];
strcpy(name, imsi);
}
};


void main()
{
Video *v[100];
Video *v4[10];
Video v3;
int i; //point index
ifstream fin;
ofstream fout;

fout.open("c:\\video3.txt", ios_base::out | ios_base::app | ios_base::binary);
fin.open("c:\\video3.txt", ios_base::in | ios_base::binary);

v[0] = new Video("kk1", 1200);
v[1] = new Video("kk2", 2200);
v[2] = new Video("kk3", 3200);


// cout << sizeof(Video) << endl;
// cout << sizeof(kk) << endl;
// cout << sizeof(kb) << endl;


//cout << v.Get_number() << " " << v.Get_name() << endl;
//cout << "size of v" << sizeof(v) << endl;


for(i = 0; i < 3; i++)
{
fout.write( (char*)v[i], sizeof(v3) );
i++;
}
fout.close();






// while(fin.read( (char*)&v3, sizeof(v3) ))
//
// {
// cout << v3.Get_name() << " : " << v3.Get_number() << endl;
//
// }
//cout << "size of v4: " << sizeof(v4[0]) << endl;
i = 0;
while(fin.read( (char*)v4[i], sizeof(v3) ) )

{
cout << v4[i]->Get_name() << " : " << v4[i]->Get_number() << endl;
i++;
}

}//main



Thank you!!

QuestionRe: i have some question about binary stream file. Pin
CPallini30-Nov-07 23:41
mveCPallini30-Nov-07 23:41 
AnswerRe: i have some question about binary stream file. Pin
buffering831-Dec-07 0:53
buffering831-Dec-07 0:53 
GeneralRe: i have some question about binary stream file. Pin
CPallini1-Dec-07 2:53
mveCPallini1-Dec-07 2:53 
GeneralRe: i have some question about binary stream file. Pin
buffering831-Dec-07 3:02
buffering831-Dec-07 3:02 
GeneralRe: i have some question about binary stream file. Pin
CPallini1-Dec-07 6:47
mveCPallini1-Dec-07 6:47 

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.