Click here to Skip to main content
16,010,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to override start button? Pin
dj44003-Sep-08 22:33
dj44003-Sep-08 22:33 
GeneralRe: how to override start button? Pin
sashoalm5-Sep-08 1:06
sashoalm5-Sep-08 1:06 
QuestionRead and write binary Pin
The ANZAC28-Aug-08 3:14
The ANZAC28-Aug-08 3:14 
AnswerRe: Read and write binary Pin
David Crow28-Aug-08 3:25
David Crow28-Aug-08 3:25 
GeneralRe: Read and write binary Pin
The ANZAC28-Aug-08 3:50
The ANZAC28-Aug-08 3:50 
GeneralRe: Read and write binary Pin
sashoalm28-Aug-08 3:56
sashoalm28-Aug-08 3:56 
GeneralRe: Read and write binary Pin
David Crow28-Aug-08 3:57
David Crow28-Aug-08 3:57 
GeneralRe: Read and write binary Pin
enhzflep28-Aug-08 4:24
enhzflep28-Aug-08 4:24 
With fopen, fread and fwrite.

Here's a rough n nasty example:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    FILE *fp;
    long i;
    long fLen;
    long tmpValue;


    // try to open an existing file
    fp = fopen("test.dat", "r+b");
    // if failed, then create a file
    if (fp == NULL)
    {
        printf("File doesn't exist\n");
        printf("creating...\n");
        fp = fopen("test.dat", "w+b");
    }
    // if file opened/created ok continue
    if (fp)
        printf("File opened successfully.\n");
    // otherwise, nick-off
    else
        return -1;

    // write some binary data to the file
    for (i=0; i<100; i++)
        fwrite(&i, sizeof(i), 1, fp);

    // get length of file
    fseek(fp, 0, SEEK_END);
    fLen = ftell(fp);

    // return file pointer to beginning of file
    fseek(fp, 0, SEEK_SET);

    // loop through, reading 1 long at a time from the file and printing it's value
    for (i=0; i<fLen/sizeof(long); i++)
    {
        fread(&tmpValue, sizeof(long), 1, fp);
        printf("%4d", tmpValue);
    }

    fclose(fp);
    return 0;
}

GeneralRe: Read and write binary Pin
The ANZAC28-Aug-08 4:30
The ANZAC28-Aug-08 4:30 
QuestionMouse Right Click Pin
MsmVc28-Aug-08 2:28
MsmVc28-Aug-08 2:28 
AnswerRe: Mouse Right Click Pin
sudhir_Kumar28-Aug-08 2:50
sudhir_Kumar28-Aug-08 2:50 
GeneralRe: Mouse Right Click Pin
MsmVc28-Aug-08 2:56
MsmVc28-Aug-08 2:56 
AnswerRe: Mouse Right Click Pin
Jijo.Raj28-Aug-08 3:16
Jijo.Raj28-Aug-08 3:16 
QuestionVisual C++6 Pin
susanne128-Aug-08 2:12
susanne128-Aug-08 2:12 
AnswerRe: Visual C++6 Pin
onlyjaypatel28-Aug-08 2:19
onlyjaypatel28-Aug-08 2:19 
AnswerRe: Visual C++6 Pin
Nibu babu thomas28-Aug-08 2:46
Nibu babu thomas28-Aug-08 2:46 
AnswerRe: Visual C++6 Pin
Jijo.Raj28-Aug-08 2:51
Jijo.Raj28-Aug-08 2:51 
GeneralRe: Visual C++6 Pin
susanne128-Aug-08 3:17
susanne128-Aug-08 3:17 
QuestionRe: Visual C++6 Pin
David Crow28-Aug-08 3:27
David Crow28-Aug-08 3:27 
GeneralRe: Visual C++6 Pin
Jijo.Raj28-Aug-08 3:29
Jijo.Raj28-Aug-08 3:29 
AnswerRe: Visual C++6 Pin
super_ttd28-Aug-08 7:33
super_ttd28-Aug-08 7:33 
GeneralRe: Visual C++6 Pin
susanne128-Aug-08 21:26
susanne128-Aug-08 21:26 
GeneralRe: Visual C++6 Pin
super_ttd30-Aug-08 23:29
super_ttd30-Aug-08 23:29 
QuestionCListCTrl Hyperlink Problem Pin
Dhiraj kumar Saini28-Aug-08 2:03
Dhiraj kumar Saini28-Aug-08 2:03 
AnswerRe: CListCTrl Hyperlink Problem Pin
Nibu babu thomas28-Aug-08 2:40
Nibu babu thomas28-Aug-08 2:40 

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.