Click here to Skip to main content
15,897,090 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionquestion about MAPI C++ and ms office outlook Pin
monsieur_jj6-Sep-07 20:02
monsieur_jj6-Sep-07 20:02 
AnswerRe: question about MAPI C++ and ms office outlook Pin
monsieur_jj6-Sep-07 22:51
monsieur_jj6-Sep-07 22:51 
Questionwhat is the message when Service abruptly stopped Pin
Yashusid6-Sep-07 18:23
Yashusid6-Sep-07 18:23 
Questionbitmaps & regions [modified] Pin
zqueezy6-Sep-07 14:39
zqueezy6-Sep-07 14:39 
AnswerRe: bitmaps & regions Pin
Mark Salsbery6-Sep-07 16:34
Mark Salsbery6-Sep-07 16:34 
AnswerRe: I solved it now! Pin
zqueezy6-Sep-07 20:57
zqueezy6-Sep-07 20:57 
GeneralRe: I solved it now! Pin
Mark Salsbery7-Sep-07 6:00
Mark Salsbery7-Sep-07 6:00 
QuestionWriting integer values to file using streams [modified] Pin
Cyrilix6-Sep-07 12:33
Cyrilix6-Sep-07 12:33 
I'm having a little trouble writing integer values to a file with ofstream objects. If I do ofstream::write(), then I have to pass it a char or a char*. So far, in my code, I've tried doing the following:

ofstream geomFile("C:\\file.dat", ios::binary);
geomFile.write((char*)ordX, sizeof(int) * numOrds);
geomFile.write((char*)ordY, sizeof(int) * numOrds);


where ordX and ordY are defined here:

const int numOrds = 10;
int ordX[numOrds];
int ordY[numOrds];


Basically, since I know the array is a contiguous memory location of 10 integers, I do a write starting from the pointer value of ordX and ordY through sizeof(int) (4) * numOrds (10) = 40 bytes. What I expect is to have 20 4-byte integers lined up in my file one after another. Unfortunately, when I read back from the file, I'm not getting the right result. Any ideas?

I guess I should also specify how I'm reading back the file using an ifstream object.

ifstream geomFile("C:\\geom.dat", ios::binary);
char readBuf[sizeof(int)];
int ordX[numOrds];

for (int i = 0; i < 10; i++)
{
    geomFile.get(readBuf, 4);
    ordX[i] = *(int*)readBuf;
}


I know the above looks a bit like a hack, but I'm sort of confused as to how I'd manipulate things in 4-byte blocks other than casting to int* and dereferencing.

-- modified at 20:45 Thursday 6th September, 2007
AnswerRe: Writing integer values to file using streams Pin
Mark Salsbery6-Sep-07 14:29
Mark Salsbery6-Sep-07 14:29 
GeneralRe: Writing integer values to file using streams Pin
Cyrilix6-Sep-07 14:36
Cyrilix6-Sep-07 14:36 
GeneralRe: Writing integer values to file using streams Pin
Mark Salsbery6-Sep-07 16:18
Mark Salsbery6-Sep-07 16:18 
GeneralRe: Writing integer values to file using streams Pin
Cyrilix6-Sep-07 16:57
Cyrilix6-Sep-07 16:57 
QuestionOverride afx msg box (pop up) Pin
AeJai6-Sep-07 10:04
AeJai6-Sep-07 10:04 
AnswerRe: Override afx msg box (pop up) Pin
Mark Salsbery6-Sep-07 13:53
Mark Salsbery6-Sep-07 13:53 
QuestionConsole redirection Pin
Waldermort6-Sep-07 9:22
Waldermort6-Sep-07 9:22 
AnswerRe: Console redirection Pin
Waldermort6-Sep-07 11:59
Waldermort6-Sep-07 11:59 
QuestionIs there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
abiemann6-Sep-07 7:00
abiemann6-Sep-07 7:00 
QuestionRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
David Crow6-Sep-07 7:09
David Crow6-Sep-07 7:09 
AnswerRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
abiemann6-Sep-07 7:36
abiemann6-Sep-07 7:36 
GeneralRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? [modified] Pin
abiemann6-Sep-07 8:03
abiemann6-Sep-07 8:03 
GeneralRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
Mark Salsbery6-Sep-07 8:22
Mark Salsbery6-Sep-07 8:22 
GeneralRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
Mark Salsbery6-Sep-07 8:27
Mark Salsbery6-Sep-07 8:27 
GeneralRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? [modified] Pin
abiemann6-Sep-07 8:33
abiemann6-Sep-07 8:33 
QuestionRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
David Crow6-Sep-07 8:41
David Crow6-Sep-07 8:41 
AnswerRe: Is there an equivalent to SuspendLayout/ResumeLayout for a MFC Dialog ? Pin
abiemann6-Sep-07 8:52
abiemann6-Sep-07 8:52 

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.