Having a string within a system()

前端 未结 2 855
孤城傲影
孤城傲影 2021-01-29 09:56

How can I use a string within a system(). ex: (input is the string)

system(\"open -a Google Chrome\" \"http://www.dictionary.reference.com/browse/\" + input + \"         


        
2条回答
  •  心在旅途
    2021-01-29 10:28

    Have you included the stdlib header?

    No matching function for call to 'system' typically occurs when it cannot resolve a function with that signature.

    EG:

    #include  // Needed for system().
    
    int main()
    {
        system("some argument"); 
        return 1;
    }
    

    And don't forget to .c_str() your std::string variable when passing it in as an argument.

    See:

    1. system() documentation.
    2. This SO answer.

提交回复
热议问题