Click here to Skip to main content
15,917,731 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralClass/es to manage AT Commands Pin
Anonymous13-Mar-03 21:57
Anonymous13-Mar-03 21:57 
GeneralRe: Class/es to manage AT Commands Pin
Daniel Strigl13-Mar-03 22:20
Daniel Strigl13-Mar-03 22:20 
GeneralWant to display current date in CDateTimeCtrl Pin
Kamesh13-Mar-03 21:46
Kamesh13-Mar-03 21:46 
Generalfunction forwarding in a DLL Pin
Fad B13-Mar-03 21:27
Fad B13-Mar-03 21:27 
GeneralRe: function forwarding in a DLL Pin
KarstenK13-Mar-03 21:40
mveKarstenK13-Mar-03 21:40 
GeneralReading arbitrary size file Pin
Makover13-Mar-03 20:36
Makover13-Mar-03 20:36 
GeneralRe: Reading arbitrary size file Pin
Fredrik Skog13-Mar-03 20:53
Fredrik Skog13-Mar-03 20:53 
GeneralRe: Reading arbitrary size file Pin
Cedric Moonen13-Mar-03 20:57
Cedric Moonen13-Mar-03 20:57 
I don't know if ther's a "standard approach" but what I'll do is first to read the string in a large buffer (large enough to store the largest string in your file) and then allocate dynamically memory for the string.

You can do it like this:

<br />
char Buffer[255];     //255 is the largest string<br />
<br />
fscanf(YourFile,"%s",Buffer);  //This will read data from a FILE* (here:  YourFile) in a formatted way)<br />
<br />
char* YourString = new char[strlen(Buffer)];   // This will allocate the exact number of char you need for your string<br />
strcpy(YourString,Buffer);<br />


Take a look at the fscanf documentation for all the format specifications and how to use it!
GeneralRe: Reading arbitrary size file Pin
Makover13-Mar-03 21:24
Makover13-Mar-03 21:24 
GeneralRe: Reading arbitrary size file Pin
Fredrik Skog13-Mar-03 21:44
Fredrik Skog13-Mar-03 21:44 
GeneralRe: Reading arbitrary size file Pin
Ted Ferenc14-Mar-03 0:26
Ted Ferenc14-Mar-03 0:26 
GeneralRe: Reading arbitrary size file Pin
jhwurmbach14-Mar-03 4:00
jhwurmbach14-Mar-03 4:00 
GeneralRe: Reading arbitrary size file Pin
KarstenK13-Mar-03 21:35
mveKarstenK13-Mar-03 21:35 
GeneralRe: Reading arbitrary size file Pin
Makover14-Mar-03 3:25
Makover14-Mar-03 3:25 
GeneralRe: Reading arbitrary size file Pin
TomKat14-Mar-03 14:33
TomKat14-Mar-03 14:33 
Generalglobal variables Pin
r i s h a b h s13-Mar-03 19:54
r i s h a b h s13-Mar-03 19:54 
GeneralRe: global variables Pin
Daniel Strigl13-Mar-03 20:00
Daniel Strigl13-Mar-03 20:00 
GeneralRe: global variables Pin
r i s h a b h s13-Mar-03 20:20
r i s h a b h s13-Mar-03 20:20 
GeneralRe: global variables Pin
Rickard Andersson2013-Mar-03 20:35
Rickard Andersson2013-Mar-03 20:35 
GeneralRe: global variables Pin
r i s h a b h s13-Mar-03 23:15
r i s h a b h s13-Mar-03 23:15 
GeneralRe: global variables Pin
Daniel Strigl13-Mar-03 21:50
Daniel Strigl13-Mar-03 21:50 
GeneralRe: global variables Pin
Joan M13-Mar-03 22:16
professionalJoan M13-Mar-03 22:16 
GeneralRe: global variables Pin
Moak14-Mar-03 10:27
Moak14-Mar-03 10:27 
GeneralRe: global variables Pin
TomKat14-Mar-03 14:35
TomKat14-Mar-03 14:35 
Generaldetecting system restart Pin
r i s h a b h s13-Mar-03 17:10
r i s h a b h s13-Mar-03 17:10 

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.