Click here to Skip to main content
15,903,385 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionToolBar "affaire" Pin
Ritxi11-Sep-08 23:07
Ritxi11-Sep-08 23:07 
AnswerRe: ToolBar "affaire" Pin
Ritxi14-Sep-08 21:54
Ritxi14-Sep-08 21:54 
QuestionProblem with ATL IE plugin programming Pin
Robert Wang198310-Sep-08 5:19
Robert Wang198310-Sep-08 5:19 
Question[Message Deleted] Pin
arkiboys10-Sep-08 3:22
arkiboys10-Sep-08 3:22 
QuestionRe: PrintUIEntry Pin
led mike10-Sep-08 5:29
led mike10-Sep-08 5:29 
QuestionWindow.close() Close Dialog Box Pin
preeti sharma10-Sep-08 2:22
preeti sharma10-Sep-08 2:22 
QuestionHow to save/load a string in STL to/from a file? Pin
followait7-Sep-08 16:30
followait7-Sep-08 16:30 
AnswerRe: How to save/load a string in STL to/from a file? Pin
Stuart Dootson9-Sep-08 22:10
professionalStuart Dootson9-Sep-08 22:10 
Are you saying you want to save a string to a file? If so, then this code illustrates how to write a string to a file and the different mechanisms available when reading strings from a file.

None of them are totally satisfactory, as it's difficult to determine where the original string's end was after it's been written to a file. To be more reliable, I'd probably write the string length out first, as that will tell you how many characters to read in. Other approaches (e.g. quoting the string) would work, but would require you to process the string, escaping quote characters.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

int main(int, char**)
{
  {
    std::ofstream a("a.a");
    std::string s = " Hello World";
    a << s << std::endl;
  }  
  {
    // This prints 'Hello', illustrating that the string extractor ( >> )
    // stops reading when it sees a whitespace and (by default) skips 
    // over leading whitespace
    std::ifstream a("a.a");
    std::string s;
    a >> s;
    std::cout << s << std::endl;
  }
  {
    // This prints '', showing how you can persuade the stream to take
    // notice of leading whitespace
    std::ifstream a("a.a");
    std::string s;
    a >> s;
    std::cout << s << std::endl;
  }
  {
    // This prints 'Hello World' - getline reads the whole line and
    // assigns it to s
    std::ifstream a("a.a");
    std::string s;
    getline(a, s);
    std::cout << s << std::endl;
  }  
}

GeneralRe: How to save/load a string in STL to/from a file? Pin
followait9-Sep-08 22:27
followait9-Sep-08 22:27 
GeneralRe: How to save/load a string in STL to/from a file? Pin
Stuart Dootson9-Sep-08 22:41
professionalStuart Dootson9-Sep-08 22:41 
GeneralRe: How to save/load a string in STL to/from a file? Pin
followait9-Sep-08 23:10
followait9-Sep-08 23:10 
GeneralRe: How to save/load a string in STL to/from a file? Pin
Stuart Dootson9-Sep-08 23:43
professionalStuart Dootson9-Sep-08 23:43 
QuestionPorting MFC SDI project to WTL Pin
dc_20006-Sep-08 8:51
dc_20006-Sep-08 8:51 
AnswerRe: Porting MFC SDI project to WTL Pin
Michael Dunn9-Sep-08 13:37
sitebuilderMichael Dunn9-Sep-08 13:37 
QuestionTabs and Accelerators in ATL Modeless Dialogs CAxWindow Pin
preeti sharma5-Sep-08 21:56
preeti sharma5-Sep-08 21:56 
QuestionATL / C++ Event handing Problem Pin
kalukaley3-Sep-08 5:15
kalukaley3-Sep-08 5:15 
AnswerRe: ATL / C++ Event handing Problem Pin
Stuart Dootson4-Sep-08 22:32
professionalStuart Dootson4-Sep-08 22:32 
GeneralRe: ATL / C++ Event handing Problem Pin
kalukaley5-Sep-08 13:55
kalukaley5-Sep-08 13:55 
GeneralRe: ATL / C++ Event handing Problem Pin
Stuart Dootson5-Sep-08 18:27
professionalStuart Dootson5-Sep-08 18:27 
GeneralRe: ATL / C++ Event handing Problem Pin
kalukaley8-Sep-08 19:29
kalukaley8-Sep-08 19:29 
QuestionCSplitterWindow flicker when resizing Pin
Nathan Going3-Sep-08 2:44
Nathan Going3-Sep-08 2:44 
QuestionRe: CSplitterWindow flicker when resizing Pin
led mike3-Sep-08 6:08
led mike3-Sep-08 6:08 
QuestionRe: CSplitterWindow flicker when resizing Pin
Nathan Going3-Sep-08 7:33
Nathan Going3-Sep-08 7:33 
AnswerRe: CSplitterWindow flicker when resizing Pin
Alain Rist5-Sep-08 21:57
Alain Rist5-Sep-08 21:57 
QuestionATL Composite Activex Pin
Member 17186003-Sep-08 0:18
Member 17186003-Sep-08 0:18 

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.