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. boost::format

boost::format

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresjsonhelptutorialquestion
7 Posts 4 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.
  • G Offline
    G Offline
    gmallax
    wrote on last edited by
    #1

    Hi all, Im having char *data = new char[256]; if i use cstring like, std::string logFolder; CString temp1; temp1.Format(L"%s",data); USES_CONVERSION; logFolder = T2A(temp1); I am able to get the correct path from data. If i use like, std::string temp; temp = (boost::format("%s") % data).str(); logFolder = temp; i cant get the correct string from data.. Anyone knows how to format the char array?Is parsing needed?Pls help me. Thanx..

    _ S 2 Replies Last reply
    0
    • G gmallax

      Hi all, Im having char *data = new char[256]; if i use cstring like, std::string logFolder; CString temp1; temp1.Format(L"%s",data); USES_CONVERSION; logFolder = T2A(temp1); I am able to get the correct path from data. If i use like, std::string temp; temp = (boost::format("%s") % data).str(); logFolder = temp; i cant get the correct string from data.. Anyone knows how to format the char array?Is parsing needed?Pls help me. Thanx..

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Try boost::format("%1%") % data

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      G 1 Reply Last reply
      0
      • _ _Superman_

        Try boost::format("%1%") % data

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        G Offline
        G Offline
        gmallax
        wrote on last edited by
        #3

        Not working.Its also gives the first letter only.. Is any other syntax to display the char array in boost format?? Pls help me.

        _ 1 Reply Last reply
        0
        • G gmallax

          Not working.Its also gives the first letter only.. Is any other syntax to display the char array in boost format?? Pls help me.

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Oh! Yes of course. You wchar_t instead of char.

          «_Superman_»
          I love work. It gives me something to do between weekends.

          Microsoft MVP (Visual C++)

          Polymorphism in C

          G 1 Reply Last reply
          0
          • _ _Superman_

            Oh! Yes of course. You wchar_t instead of char.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            G Offline
            G Offline
            gmallax
            wrote on last edited by
            #5

            It does not give the correct value..It gives some abnormal value.

            1 Reply Last reply
            0
            • G gmallax

              Hi all, Im having char *data = new char[256]; if i use cstring like, std::string logFolder; CString temp1; temp1.Format(L"%s",data); USES_CONVERSION; logFolder = T2A(temp1); I am able to get the correct path from data. If i use like, std::string temp; temp = (boost::format("%s") % data).str(); logFolder = temp; i cant get the correct string from data.. Anyone knows how to format the char array?Is parsing needed?Pls help me. Thanx..

              S Offline
              S Offline
              Stephen Hewitt
              wrote on last edited by
              #6

              This code works fine for me:

              // Console.cpp : Defines the entry point for the console application.
              //

              #include "stdafx.h"
              #include <tchar.h>
              #include <iostream>
              #include <boost/format.hpp>

              using namespace std;

              int _tmain(int argc, _TCHAR* argv[])
              {
              using namespace boost;

              const char \*pData = "world";
              format fmt("Hello %1%!");
              fmt % pData;
              cout << fmt;
              
              cout << endl;
              
              return 0;
              

              }

              The output is:

              Hello world!

              Steve

              N 1 Reply Last reply
              0
              • S Stephen Hewitt

                This code works fine for me:

                // Console.cpp : Defines the entry point for the console application.
                //

                #include "stdafx.h"
                #include <tchar.h>
                #include <iostream>
                #include <boost/format.hpp>

                using namespace std;

                int _tmain(int argc, _TCHAR* argv[])
                {
                using namespace boost;

                const char \*pData = "world";
                format fmt("Hello %1%!");
                fmt % pData;
                cout << fmt;
                
                cout << endl;
                
                return 0;
                

                }

                The output is:

                Hello world!

                Steve

                N Offline
                N Offline
                Niklas L
                wrote on last edited by
                #7

                Stephen Hewitt wrote:

                The output is: Hello world!

                and there it is. You dropped the bomb...

                home

                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