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. Managed C++/CLI
  4. Converting a C++ style string into something execvp can use.

Converting a C++ style string into something execvp can use.

Scheduled Pinned Locked Moved Managed C++/CLI
questionc++help
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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    I have made a program to except user's input and use that input to execvp another program. The problem is that execvp has a prototype of int execvp(const char *file, char *const argv[]); and the user's input is a c++ style string (string input for instance). How can I convert that c++ style string into something at execvp can use? the c_str() function DOES NOT work.

    C 1 Reply Last reply
    0
    • A Anonymous

      I have made a program to except user's input and use that input to execvp another program. The problem is that execvp has a prototype of int execvp(const char *file, char *const argv[]); and the user's input is a c++ style string (string input for instance). How can I convert that c++ style string into something at execvp can use? the c_str() function DOES NOT work.

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

      Which argument are you having trouble with ? What format is the string you're getting as input ? c_str() does indeed return a char *, if you've got a std::string. argv is an array of char *, not just a char *. What do you mean by 'it doesn't work'. A more meaningful error report would help those trying to help you. Christian Graus - Microsoft MVP - C++

      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