[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.

posted @ 2010-02-21 16:16  能巴  阅读(209)  评论(0编辑  收藏  举报