Click here to Skip to main content
15,900,524 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to share a pointer between an EXE and a DLL Pin
Mircea Neacsu12-Jul-22 12:17
Mircea Neacsu12-Jul-22 12:17 
GeneralRe: How to share a pointer between an EXE and a DLL Pin
JudyL_MD12-Jul-22 13:29
JudyL_MD12-Jul-22 13:29 
AnswerRe: How to share a pointer between an EXE and a DLL Pin
Graham Breach11-Jul-22 20:30
Graham Breach11-Jul-22 20:30 
AnswerRe: How to share a pointer between an EXE and a DLL Pin
Gerry Schmitz12-Jul-22 6:57
mveGerry Schmitz12-Jul-22 6:57 
QuestionVC++/MFC Pin
Member 1486933911-Jul-22 8:22
Member 1486933911-Jul-22 8:22 
AnswerRe: VC++/MFC Pin
Dave Kreskowiak11-Jul-22 9:55
mveDave Kreskowiak11-Jul-22 9:55 
AnswerRe: VC++/MFC Pin
Victor Nijegorodov11-Jul-22 9:56
Victor Nijegorodov11-Jul-22 9:56 
GeneralRe: VC++/MFC Pin
Member 1486933912-Jul-22 20:45
Member 1486933912-Jul-22 20:45 
QuestionRe: VC++/MFC Pin
Richard MacCutchan12-Jul-22 21:42
mveRichard MacCutchan12-Jul-22 21:42 
GeneralRe: VC++/MFC Pin
Victor Nijegorodov13-Jul-22 0:22
Victor Nijegorodov13-Jul-22 0:22 
AnswerRe: VC++/MFC Pin
Gerry Schmitz11-Jul-22 12:21
mveGerry Schmitz11-Jul-22 12:21 
AnswerRe: VC++/MFC Pin
Richard MacCutchan11-Jul-22 21:33
mveRichard MacCutchan11-Jul-22 21:33 
QuestionMessage Closed Pin
8-Jul-22 6:24
Member 149687718-Jul-22 6:24 
GeneralRe: how to start QProcess not coding argument parameter ? Pin
Richard MacCutchan8-Jul-22 7:53
mveRichard MacCutchan8-Jul-22 7:53 
AnswerRe: how to start QProcess not coding argument parameter ? Pin
jeron18-Jul-22 10:21
jeron18-Jul-22 10:21 
Question[Solved] Sending input to system("command") prompt Windows Pin
JohnCodding6-Jul-22 22:51
JohnCodding6-Jul-22 22:51 
GeneralRe: Sending input to system("command") prompt Windows Pin
Richard MacCutchan7-Jul-22 0:06
mveRichard MacCutchan7-Jul-22 0:06 
GeneralRe: Sending input to system("command") prompt Windows Pin
Greg Utas7-Jul-22 0:14
professionalGreg Utas7-Jul-22 0:14 
GeneralRe: Sending input to system("command") prompt Windows Pin
Richard MacCutchan7-Jul-22 1:25
mveRichard MacCutchan7-Jul-22 1:25 
GeneralRe: Sending input to system("command") prompt Windows Pin
JohnCodding7-Jul-22 0:15
JohnCodding7-Jul-22 0:15 
GeneralRe: Sending input to system("command") prompt Windows Pin
JohnCodding7-Jul-22 0:20
JohnCodding7-Jul-22 0:20 
GeneralRe: Sending input to system("command") prompt Windows Pin
Victor Nijegorodov7-Jul-22 0:29
Victor Nijegorodov7-Jul-22 0:29 
GeneralRe: Sending input to system("command") prompt Windows Pin
JohnCodding7-Jul-22 0:54
JohnCodding7-Jul-22 0:54 
QuestionRe: [Solved] Sending input to system("command") prompt Windows Pin
David Crow7-Jul-22 2:11
David Crow7-Jul-22 2:11 
QuestionConvert function to read from string instead of file in C Pin
sahil Ranka6-Jul-22 0:19
sahil Ranka6-Jul-22 0:19 
I've been tasked with updating a function which currently reads in a configuration file from disk and populates a structure:

static int LoadFromFile(FILE *Stream, ConfigStructure *cs)
{
  int tempInt;

   ...

  if ( fscanf( Stream, "Version: %d\n",&tempInt) != 1 )
  {
    printf("Unable to read version number\n");
    return 0;
  }
  cs->Version = tempInt;
   ...

}

to one which allows us to bypass writing the configuration to disk and instead pass it directly in memory, roughly equivalent to this:
static int LoadFromString(char *Stream, ConfigStructure *cs)

A couple of things to note:

• The current LoadFromFile function is incredibly dense and complex, reading dozens of versions of the config file in a backward-compatible manner, which makes duplication of the overall logic quite a pain.
• The functions that generate the config file and those that read it originate in totally different parts of the old system and therefore don't share any data structures so I can't pass those directly. I could potentially write a wrapper, but again, it would need to handle any structure passed in a backward-compatible manner.
• I'm tempted to just pass the file as is in as a string (as in the prototype above) and convert all the fscanf's to sscanf's but then I have to handle incrementing the pointer along (and potentially dealing with buffer overrun errors) manually.
• This has to remain in C, so no C++ functionality like streams can help here

Am I missing a superior choice? Is there a good method for making a FILE * that simply focuses to an area in memory rather than on a disk? Any pointers, ideas or other assistance is enormously valuable.

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.