This is a creation in Article, where the information may have evolved or changed.
Call EXE
Func callEXE1 () {arg: = []string{}cmd: = Exec.command ("Test", arg ...) will be to CMD. StdOut and Cmd.stderr write information, in fact cmd. Stdout==cmd. Stderr, specifically visible source output, err: = Cmd.combinedoutput () if err! = Nil {fmt. Println ("Error:", err) return}fmt. Printf ("callEXE2 Result: \n%v\n\n%v\n\n%v", string (output), cmd. Stdout, CMD. Stderr)}func callEXE2 () {arg: = []string{}cmd: = Exec.command ("Test", arg ...) will be to CMD. StdOut writes the information output, err: = cmd. Output () if err! = Nil {fmt. Printf ("Error:%s\n", err) return}fmt. Printf ("callEXE2 Result: \n%v\n%v\n%v", string (output), cmd. Stdout, CMD. STDERR)}
Test.exe Source:
vs. C + + #include "stdafx.h" #include <iostream>using namespace std;int _tmain (int argc, _tchar* argv[]) {std:: cout<< "China, zhongguo2014" <<endl;//std::cerr<< "China, zhongguo2014" <<endl;//std::clog<< "China, zhongguo2014" <<endl;fprintf (stderr, "China, zhongguo2013");//fprintf (stdout, "China, zhongguo2013"); return 0;}