Click here to Skip to main content
15,913,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Fix extension for CFileDialog for file saving !!! Pin
Le@rner29-Jul-08 0:39
Le@rner29-Jul-08 0:39 
GeneralRe: Fix extension for CFileDialog for file saving !!! Pin
ThatsAlok29-Jul-08 1:13
ThatsAlok29-Jul-08 1:13 
AnswerRe: Fix extension for CFileDialog for file saving !!! Pin
krmed29-Jul-08 0:46
krmed29-Jul-08 0:46 
Questionwriting and reading BYTE array Pin
subramanyeswari28-Jul-08 19:07
subramanyeswari28-Jul-08 19:07 
AnswerRe: writing and reading BYTE array Pin
Cedric Moonen28-Jul-08 20:20
Cedric Moonen28-Jul-08 20:20 
GeneralRe: writing and reading BYTE array Pin
subramanyeswari28-Jul-08 20:59
subramanyeswari28-Jul-08 20:59 
GeneralRe: writing and reading BYTE array Pin
Cedric Moonen28-Jul-08 21:27
Cedric Moonen28-Jul-08 21:27 
AnswerRe: writing and reading BYTE array Pin
CPallini28-Jul-08 21:28
mveCPallini28-Jul-08 21:28 
subramanyeswari wrote:
I used fwrite and fread but it is not working.

(Un)fortunately It doesn't depend on fwrite and fread, my friend.

The following works for me (error checking left as exercise)
int main()
{  
  {
    BYTE bValue[]={2,4,8};
    // Length of the array
    int iLen = sizeof(bValue)/sizeof(bValue[0]);
    // WRITE array
    // open file for output  in binary mode
    FILE * fpo = fopen("foo.bin", "wb");
    // store array length
    fwrite(&iLen, sizeof(iLen), 1,fpo);
    // store array elements
    fwrite(bValue, sizeof(bValue), 1, fpo);
    fclose(fpo);
  }

  {
    BYTE * bValue;
    // READ array
    // open file for input in binary mode
    FILE * fpi = fopen("foo.bin", "rb");
    int iLen;
    // read array length
    fread(&iLen, sizeof(iLen), 1,fpi);
    // read array elements
    bValue = new BYTE[iLen];
    fread(bValue, sizeof(BYTE), iLen, fpi);
    fclose(fpi);
    // use values
    // ...
    //Cleanup
    delete [] bValue;
  }
  return 0;
}


Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke


[My articles]

Questionexit button on top right corner should be disabled Pin
VCProgrammer28-Jul-08 18:31
VCProgrammer28-Jul-08 18:31 
AnswerRe: exit button on top right corner should be disabled Pin
_AnsHUMAN_ 28-Jul-08 18:52
_AnsHUMAN_ 28-Jul-08 18:52 
Questionproblem with dll Pin
prithaa28-Jul-08 18:30
prithaa28-Jul-08 18:30 
AnswerRe: problem with dll Pin
Cedric Moonen28-Jul-08 20:23
Cedric Moonen28-Jul-08 20:23 
GeneralRe: problem with dll Pin
prithaa28-Jul-08 20:52
prithaa28-Jul-08 20:52 
GeneralRe: problem with dll Pin
Cedric Moonen28-Jul-08 20:55
Cedric Moonen28-Jul-08 20:55 
QuestionUSB Monitor Pin
mirtu28-Jul-08 18:21
mirtu28-Jul-08 18:21 
AnswerRe: USB Monitor Pin
mirtu28-Jul-08 23:32
mirtu28-Jul-08 23:32 
AnswerRe: USB Monitor Pin
mirtu30-Jul-08 17:58
mirtu30-Jul-08 17:58 
QuestionI am calling void SearchDialog::OnSearchBtn() from a thread. Pin
ptr_Electron28-Jul-08 18:09
ptr_Electron28-Jul-08 18:09 
Questiondll problem Pin
prithaa28-Jul-08 17:27
prithaa28-Jul-08 17:27 
AnswerRe: dll problem Pin
ramana.g28-Jul-08 18:33
ramana.g28-Jul-08 18:33 
GeneralRe: dll problem Pin
prithaa28-Jul-08 18:47
prithaa28-Jul-08 18:47 
GeneralRe: dll problem Pin
Nibu babu thomas28-Jul-08 21:48
Nibu babu thomas28-Jul-08 21:48 
AnswerRe: dll problem Pin
sashoalm28-Jul-08 20:54
sashoalm28-Jul-08 20:54 
GeneralRe: dll problem Pin
prithaa28-Jul-08 21:11
prithaa28-Jul-08 21:11 
GeneralRe: dll problem Pin
sashoalm28-Jul-08 22:46
sashoalm28-Jul-08 22:46 

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.