Click here to Skip to main content
15,909,829 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionDeleting from a binary search tree Pin
darylesha12-Nov-05 17:48
darylesha12-Nov-05 17:48 
AnswerRe: Deleting from a binary search tree Pin
Nish Nishant14-Nov-05 4:10
sitebuilderNish Nishant14-Nov-05 4:10 
Questionrandom number generation problem in C++ Pin
amarsankar11-Nov-05 18:07
amarsankar11-Nov-05 18:07 
QuestionValues of 5.1 soundcard and graphic equlizer Pin
werner2711-Nov-05 1:50
werner2711-Nov-05 1:50 
AnswerRe: Values of 5.1 soundcard and graphic equlizer Pin
mikanu15-Nov-05 8:35
mikanu15-Nov-05 8:35 
QuestionHelp with connect 4 AI Pin
daham0810-Nov-05 13:26
daham0810-Nov-05 13:26 
AnswerRe: Help with connect 4 AI Pin
Jeremy Thornton12-Nov-05 14:24
Jeremy Thornton12-Nov-05 14:24 
Questionfstreaming a whole object (pointer) Pin
Hmmkk10-Nov-05 11:56
Hmmkk10-Nov-05 11:56 
I have a class called HotelRoom, and I create hotelRooms by doing this:
extern HotelRoom *hotelRooms[10];
in a header file.
This is my try to save this pointer to a file:

void saveFile()
{
char filename[100] = "HotelRegister.dat";
ofstream f(filename);
for (int i = 0; i < 10; i++)
{
f.write((char*) &hotelRooms[i], sizeof(hotelRooms[i]));
}
f.close();
}

void loadFile()
{
char filename[100] = "HotelRegister.dat";
ifstream f(filename);
for (int i = 0; i < 10; i++)
{
//hotelRooms[i] = new HotelRoom();
f.read((char*) &hotelRooms[i], sizeof(hotelRooms[i]));
}
f.close();
}
These 2 functions are aswell extern decleared in the header file.
I have already tested to take away the [i] and for loops but that gives same result, so my conclusion would be that the program crashes(runtime error) because of a memory problem caused by hotelRooms being a pointer and beacause it somewhy doesn't get initialized right?
//for(i = 0; i < 10; i++)
//hotelRooms[i] = new HotelRoom(ROOM_LUXURYCLASS, true, "Hmm kk");
//hotelRooms[i] = new HotelRoom();
//saveFile();
loadFile();
Some of it is commentated because I have tested and switched between those.
I hope someone know about pointers like this alittle better and can help me with this problem
Thanks in advance!

Best Regards,
Hmmkk
AnswerRe: fstreaming a whole object (pointer) Pin
Christian Graus10-Nov-05 12:49
protectorChristian Graus10-Nov-05 12:49 
GeneralRe: fstreaming a whole object (pointer) Pin
Hmmkk10-Nov-05 19:29
Hmmkk10-Nov-05 19:29 
GeneralRe: fstreaming a whole object (pointer) Pin
Christian Graus13-Nov-05 9:53
protectorChristian Graus13-Nov-05 9:53 
QuestionReading/editing registry on different .dat file? Pin
LordZoster9-Nov-05 11:40
LordZoster9-Nov-05 11:40 
Questionbinary hex conversion using stacks Pin
OttawaSenator9-Nov-05 6:57
OttawaSenator9-Nov-05 6:57 
AnswerRe: binary hex conversion using stacks Pin
mikanu9-Nov-05 7:12
mikanu9-Nov-05 7:12 
GeneralRe: binary hex conversion using stacks Pin
OttawaSenator9-Nov-05 11:10
OttawaSenator9-Nov-05 11:10 
GeneralRe: binary hex conversion using stacks Pin
mikanu10-Nov-05 16:32
mikanu10-Nov-05 16:32 
Question&quot;please help assignment due soon&quot; Pin
da_comp_learner7-Nov-05 16:07
da_comp_learner7-Nov-05 16:07 
AnswerRe: &amp;quot;please help assignment due soon&amp;quot; Pin
Christian Graus7-Nov-05 16:26
protectorChristian Graus7-Nov-05 16:26 
Questionmemory leak Pin
nineofhearts7-Nov-05 11:37
nineofhearts7-Nov-05 11:37 
AnswerRe: memory leak Pin
Christian Graus7-Nov-05 12:25
protectorChristian Graus7-Nov-05 12:25 
GeneralRe: memory leak Pin
nineofhearts7-Nov-05 13:21
nineofhearts7-Nov-05 13:21 
GeneralRe: memory leak Pin
Christian Graus7-Nov-05 13:41
protectorChristian Graus7-Nov-05 13:41 
GeneralRe: memory leak Pin
Christian Graus7-Nov-05 13:47
protectorChristian Graus7-Nov-05 13:47 
GeneralRe: memory leak Pin
nineofhearts7-Nov-05 15:59
nineofhearts7-Nov-05 15:59 
GeneralRe: memory leak Pin
Christian Graus7-Nov-05 16:02
protectorChristian Graus7-Nov-05 16:02 

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.