Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Output STL string into file.

Output STL string into file.

Scheduled Pinned Locked Moved C / C++ / MFC
c++businesstutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Liu
    wrote on last edited by
    #1

    How to output string into a file? My part of code is below:(Look at the last line, it is not ok.) // Open the file ready write if((pOutputFileStream = fopen(csFilePath, "w")) != NULL) bStatus = TRUE; // Otherwise output message to the console window. else { printf("The output %s file is not available!", csFilePath); bStatus = FALSE; } if (bStatus) { // STL string. string str = vNode.back (); cout << str << endl; // // this line is not ok. // fprintf(pOutputFileStream, "%s", str.substr); } Thanks. mIchAel Liu __________________________________________________________ The secret of business is to know something that nobody else knows. ;)

    C 1 Reply Last reply
    0
    • M Michael Liu

      How to output string into a file? My part of code is below:(Look at the last line, it is not ok.) // Open the file ready write if((pOutputFileStream = fopen(csFilePath, "w")) != NULL) bStatus = TRUE; // Otherwise output message to the console window. else { printf("The output %s file is not available!", csFilePath); bStatus = FALSE; } if (bStatus) { // STL string. string str = vNode.back (); cout << str << endl; // // this line is not ok. // fprintf(pOutputFileStream, "%s", str.substr); } Thanks. mIchAel Liu __________________________________________________________ The secret of business is to know something that nobody else knows. ;)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use C++ instead of C. Longer reply in ATL/WTL/STL. I should add that if you're stuck with C files, you can use the c_str() function of a std::string to get a const char *. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups