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. A C++ Question

A C++ Question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
3 Posts 3 Posters 1 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.
  • F Offline
    F Offline
    False Chicken
    wrote on last edited by
    #1

    Im trying to convert a string to a Const Char* How do I do that? Im using Dev and this is ther error i get: cannot convert `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to `const char*' for argument `1' to `int system(const char*)' (Im new to C++)

    Y*Live Long And Prosper*Y

    N T 2 Replies Last reply
    0
    • F False Chicken

      Im trying to convert a string to a Const Char* How do I do that? Im using Dev and this is ther error i get: cannot convert `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to `const char*' for argument `1' to `int system(const char*)' (Im new to C++)

      Y*Live Long And Prosper*Y

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      False Chicken wrote:

      Im trying to convert a string to a Const Char* How do I do that? Im using Dev and this is ther error i get: cannot convert `std::basic_string<char,>, std::allocator >' to `const char*' for argument `1' to `int system(const char*)'

      This way! string StrSysCommand = "cls"; system( StrSysCommand.c_str() );

      Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

      1 Reply Last reply
      0
      • F False Chicken

        Im trying to convert a string to a Const Char* How do I do that? Im using Dev and this is ther error i get: cannot convert `std::basic_string<char, std::char_traits<char>, std::allocator<char> >' to `const char*' for argument `1' to `int system(const char*)' (Im new to C++)

        Y*Live Long And Prosper*Y

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        False Chicken wrote:

        Im new to C++

        that doesn't forbids you to interrogate the documentation... the std::string class (which is a specialization of the std::basic_string template class) has a c_str()[^] member function...

        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        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