[Tip: main return value]Return value to command line

As we know, for main, it's so common to see it looks like below:

int main()

{

// do your work.

return 0;

}

At least for a console application, the returned value 0 here can be consumed later in script tool using below lines (into a bat file):

@echo off
ConsoleApplication1.exe arg1 arg2
echo Result is “%errorlevel%”
pause

 

Here, “%errorlevel%” will get 0 which is main function's return value.

你可能感兴趣的:(command)