我如何获取C语言中的主函数返回值? [英] how do i get main function return value in C language?

查看:584
本文介绍了我如何获取C语言中的主函数返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google上进行了搜索,但无法获得该问题的正确答案..
我的程序是:-

I searched on google but I could not get the practically right answer for this question..
My program is :-

#include<stdio.h>
#include<conio.h>
int main()
{
	int temp;
	clrscr();
	printf("Enter Number : ");
	scanf("%d",&temp);
	return temp;
}



如何通过主函数(在运行时)获取temp变量的值?
我正在使用Dos Box C IDE和Windows 7(64位).

感谢高级....



How do i get the temp variable''s value by main function(at runtime)??
I''m using Dos Box C IDE, and windows 7(64bit).

thanks in advanced...

推荐答案

此返回值是父进程可以获取的值.您已获得有关如何在批处理脚本中获取此值的答案,但是任何其他进程都可以获取它.此返回值称为退出状态.您可以在这里阅读有关信息:
http://en.wikipedia.org/wiki/Main_function [ http://en.wikipedia.org/wiki/Exit_status [
随着时间的流逝,这种弱定义的实体作为退出代码的使用有所减少.许多应用程序,尤其是带有GUI的应用程序主要忽略该值,总是返回0.在仅控制台的应用程序中,使用它更为常见.

—SA
This return value is the value which a parent process can get. You got an answer on how to get this value in a batch script, but any other process can get it. This return value is called exit status. You can read about it here:
http://en.wikipedia.org/wiki/Main_function[^],
http://en.wikipedia.org/wiki/Exit_status[^].

The returned value does not have special predefined meaning and is fully defined by the application, but zero is usually used to conduct the "complete without any problems" idea. The way of getting this value depends on the platform, but multiplatform programming systems/language may have some common API for spawning a child process, and, in such cases, the API usually provides a way to read exit code.

With time, the use of such a weakly defined entity as exit code somewhat declined. Many application, especially those with GUI majorly ignore the value, always returning 0. In console-only applications, using it is more usual.

—SA


这篇关于我如何获取C语言中的主函数返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆