I want to call an c++ exe file into my c# application that takes a command line argument and returns the result so that i can use it in my c# application but i don't know how to do it .
here's the simple sample that i tried and failed : c++ code : returner.exe
#include<iostream>
#include<cstdlib>
using namespace std;
int main(string argc , string argv)
{
int b= atoi(argv.c_str());
return b;
}
c# code :
private void button1_Click(object sender, EventArgs e)
{
ProcessStartInfo stf = new ProcessStartInfo("returner.exe", "3");
stf.RedirectStandardOutput = true;
stf.UseShellExecute = false;
stf.CreateNoWindow = true;
using (Process p = Process.Start(stf))
{
p.WaitForExit();
int a = p.ExitCode;
label1.Text = a.ToString();
}
}
i expect to see 3 in the lable . but it's always 0 . what should i do ?
mainsignature is not standard.int main(int argc, const char** argv)-> this is a correct prototype for the main function. From that you should perhaps be able to do something