Click here to Skip to main content
15,868,016 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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.
AnswerRe: Convert function to read from string instead of file in C Pin
Mircea Neacsu6-Jul-22 0:49
Mircea Neacsu6-Jul-22 0:49 
AnswerRe: Convert function to read from string instead of file in C Pin
Richard MacCutchan6-Jul-22 1:19
mveRichard MacCutchan6-Jul-22 1:19 
QuestionRe: Convert function to read from string instead of file in C Pin
David Crow6-Jul-22 4:38
David Crow6-Jul-22 4:38 
QuestionConvert curl request Pin
_Flaviu4-Jul-22 3:14
_Flaviu4-Jul-22 3:14 
AnswerRe: Convert curl request Pin
k50544-Jul-22 4:39
mvek50544-Jul-22 4:39 
GeneralRe: Convert curl request Pin
_Flaviu4-Jul-22 4:52
_Flaviu4-Jul-22 4:52 
GeneralRe: Convert curl request Pin
k50544-Jul-22 5:25
mvek50544-Jul-22 5:25 
GeneralRe: Convert curl request Pin
_Flaviu4-Jul-22 5:43
_Flaviu4-Jul-22 5:43 
GeneralRe: Convert curl request Pin
k50544-Jul-22 6:17
mvek50544-Jul-22 6:17 
GeneralRe: Convert curl request Pin
_Flaviu4-Jul-22 7:10
_Flaviu4-Jul-22 7:10 
GeneralRe: Convert curl request Pin
k50544-Jul-22 7:17
mvek50544-Jul-22 7:17 
GeneralRe: Convert curl request Pin
_Flaviu4-Jul-22 7:31
_Flaviu4-Jul-22 7:31 
GeneralRe: Convert curl request Pin
Richard MacCutchan4-Jul-22 9:21
mveRichard MacCutchan4-Jul-22 9:21 
GeneralRe: Convert curl request Pin
_Flaviu4-Jul-22 19:48
_Flaviu4-Jul-22 19:48 
GeneralRe: Convert curl request Pin
k50544-Jul-22 9:26
mvek50544-Jul-22 9:26 
QuestionAmazing C/C++ and C# and Python performance test Pin
Code4Ever2-Jul-22 6:48
Code4Ever2-Jul-22 6:48 
AnswerRe: Amazing C/C++ and C# and Python performance test Pin
Gerry Schmitz2-Jul-22 7:02
mveGerry Schmitz2-Jul-22 7:02 

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.