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

C / C++ / MFC

 
GeneralHook Trouble Pin
Ernesto D.23-Nov-03 16:15
Ernesto D.23-Nov-03 16:15 
GeneralRe: Hook Trouble Pin
James Brown24-Nov-03 7:44
James Brown24-Nov-03 7:44 
GeneralRe: Hook Trouble Pin
Ernesto D.24-Nov-03 9:19
Ernesto D.24-Nov-03 9:19 
GeneralRead This Pin
LOSTTWARE.com23-Nov-03 16:06
LOSTTWARE.com23-Nov-03 16:06 
GeneralI tried this Pin
LOSTTWARE.com23-Nov-03 16:08
LOSTTWARE.com23-Nov-03 16:08 
GeneralRe: Read This Pin
Ernesto D.23-Nov-03 16:28
Ernesto D.23-Nov-03 16:28 
GeneralRe: Read This Pin
LOSTTWARE.com23-Nov-03 17:13
LOSTTWARE.com23-Nov-03 17:13 
GeneralRe: Read This Pin
John R. Shaw23-Nov-03 17:44
John R. Shaw23-Nov-03 17:44 
1) fprintf(fp,"%d",test1 test2);

How did this compile?

If the line was "fprintf(fp,"%d",test1, test2);" then it would make since.

OH by the way: fopen("Test.startup","w") and fopen("Test.startup","r") assumes that you are loading binary data not text data. Use fopen("Test.startup","wt") and fopen("Test.startup","rt") when working with text file.

If you want to store characters '1' and '2' to a file:
char test1 = '1';
char test2 = '2';
FILE *fp = fopen("Test.startup","wt");
if(fp)
{
    fprintf(fp,"%c%c",test1, test2);
    fclose(fp);
}

If you want to load characters '1' and '2' from a file:
char test1;
char test2;

FILE *fp=fopen("Test.startup","rt");
if(fp)
{
    if( fscanf(fp,"%c%c", &test1, &test2) )
    {
        // Some Code
    }
    fclose(fp);
}


From what I have seen, all you need to do is study the documentation for file I/O. I know peaple ar going to throw iostream a you as a suposably better solution. But 90% of the time it is just a wrapper for for what you are doing.

Writing chacaters to a file using fprintf() is ok, but reading them with fsprintf() has (almost always) been a joke.

Before you use iostream you must understand reading a file at the system level (a.k.a. C level).


INTP
GeneralRe: Read This Pin
David Crow24-Nov-03 2:48
David Crow24-Nov-03 2:48 
GeneralRe: Read This Pin
John R. Shaw24-Nov-03 5:46
John R. Shaw24-Nov-03 5:46 
Generalabout compilers! Pin
shaddonah23-Nov-03 16:02
shaddonah23-Nov-03 16:02 
GeneralRe: about compilers! Pin
Hadi Rezaee23-Nov-03 17:19
Hadi Rezaee23-Nov-03 17:19 
GeneralRe: about compilers! Pin
shaddonah27-Nov-03 9:01
shaddonah27-Nov-03 9:01 
GeneralMFC Menu Graying. Pin
kiasu_kid23-Nov-03 14:44
kiasu_kid23-Nov-03 14:44 
GeneralRe: MFC Menu Graying. Pin
Terry O'Nolley23-Nov-03 14:49
Terry O'Nolley23-Nov-03 14:49 
GeneralRe: MFC Menu Graying. Pin
kiasu_kid23-Nov-03 14:59
kiasu_kid23-Nov-03 14:59 
GeneralRe: MFC Menu Graying. Pin
John R. Shaw23-Nov-03 15:59
John R. Shaw23-Nov-03 15:59 
GeneralRe: MFC Menu Graying. Pin
kiasu_kid23-Nov-03 18:26
kiasu_kid23-Nov-03 18:26 
GeneralRe: MFC Menu Graying. Pin
jbarton24-Nov-03 3:18
jbarton24-Nov-03 3:18 
Questionhow could i draw an irregular dialog according to an image Pin
ttemp200223-Nov-03 14:26
ttemp200223-Nov-03 14:26 
AnswerRe: how could i draw an irregular dialog according to an image Pin
Prakash Nadar23-Nov-03 16:41
Prakash Nadar23-Nov-03 16:41 
AnswerRe: how could i draw an irregular dialog according to an image Pin
John R. Shaw23-Nov-03 16:57
John R. Shaw23-Nov-03 16:57 
GeneralSetWindowLong indicates blocked thread. Pin
suninwater23-Nov-03 13:42
suninwater23-Nov-03 13:42 
GeneralRe: SetWindowLong indicates blocked thread. Pin
Prakash Nadar23-Nov-03 16:47
Prakash Nadar23-Nov-03 16:47 
GeneralCreateDIBSection Pin
John R. Shaw23-Nov-03 12:58
John R. Shaw23-Nov-03 12:58 

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.