使用vs2010编写任何程序都会出现返回值为 0 (0x0)。 10
#include<stdio.h>main{printf("a=%4d;b=%-6.2f,c=%c,d=%s",12,3.456,'A',"hello");}“hello...
#include<stdio.h>
main
{
printf("a=%4d;b=%-6.2f,c=%c,d=%s",12,3.456 ,'A',"hello");
}
“hello world.exe”: 已加载“C:\Users\ale\Documents\Visual Studio 2010\Projects\hello world\Debug\hello world.exe”,已加载符号。
“hello world.exe”: 已加载“C:\Windows\System32\ntdll.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\kernel32.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\KernelBase.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\msvcr100d.dll”,已加载符号。
程序“[1636] hello world.exe: 本机”已退出,返回值为 0 (0x0)。
我是初学者,希望大家能帮帮我... 展开
main
{
printf("a=%4d;b=%-6.2f,c=%c,d=%s",12,3.456 ,'A',"hello");
}
“hello world.exe”: 已加载“C:\Users\ale\Documents\Visual Studio 2010\Projects\hello world\Debug\hello world.exe”,已加载符号。
“hello world.exe”: 已加载“C:\Windows\System32\ntdll.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\kernel32.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\KernelBase.dll”,Cannot find or open the PDB file
“hello world.exe”: 已加载“C:\Windows\System32\msvcr100d.dll”,已加载符号。
程序“[1636] hello world.exe: 本机”已退出,返回值为 0 (0x0)。
我是初学者,希望大家能帮帮我... 展开
展开全部
#include <stdlib.h>
#include <stdio.h>
// 定义加法函数
int Add(int a, int b)
{
__asm
{
// 将变量a的值传送给eax寄存器
MOV EAX, a
// 将变量b的值传送给ebx寄存器
MOV EBX, b
// 执行加法指令, 结果保存在eax寄存器中
ADD EAX, EBX;
}
}
int Get()
{
// 将值100传送到eax寄存器中
__asm MOV EAX, 100
}
int main(int argc, char* argv[])
{
int n = Add(10, 20);
printf("%d\n", n);
n = Get();
printf("%d\n", n);
// 通过运行上述两段代码可以发现:
// 所谓的返回值是通过CPU的寄存器返回的也就是说,
// C语言的return语句做了两件事情:
// 1. 将返回值送入eax寄存器
// 2. 从栈中获取调用函数前的代码地址, 送入EIP寄存器
system("pause");
return 0;
}
————————————————————————————————————
#include <stdio.h>
#include <stdlib.h>
/**
* 如下4种形式都可以称为主函数, 其中:
* 第一种是标准main函数, 具有argc和argv两个参数, 返回类型为int
* 第二种仅具有返回类型, 不具备参数列表
* 第三种返回类型为空, 不具备参数列表
* 第四种没有返回类型, 不具备参数列表, 但编译时会自动设置返回类型为int
*/
//int main(int argc, char* argv[])
//int main()
//void main()
main()
{
printf("Hello World\n");
system("pause");
return 0;
}
一个函数的函数名既是该函数的代表,也是一个变量。由于函数名变量通常用来把函数的处理结果数据带回给调用函数,即递归调用,所以一般把函数名变量称为返回值。 函数可以有返回值,也可以没有返回值。一般情况下不要省略返回值的类型,C语言默认返回类型为int,C++默认为void,如果省略了,就会按照默认返回值处理。
#include <stdio.h>
// 定义加法函数
int Add(int a, int b)
{
__asm
{
// 将变量a的值传送给eax寄存器
MOV EAX, a
// 将变量b的值传送给ebx寄存器
MOV EBX, b
// 执行加法指令, 结果保存在eax寄存器中
ADD EAX, EBX;
}
}
int Get()
{
// 将值100传送到eax寄存器中
__asm MOV EAX, 100
}
int main(int argc, char* argv[])
{
int n = Add(10, 20);
printf("%d\n", n);
n = Get();
printf("%d\n", n);
// 通过运行上述两段代码可以发现:
// 所谓的返回值是通过CPU的寄存器返回的也就是说,
// C语言的return语句做了两件事情:
// 1. 将返回值送入eax寄存器
// 2. 从栈中获取调用函数前的代码地址, 送入EIP寄存器
system("pause");
return 0;
}
————————————————————————————————————
#include <stdio.h>
#include <stdlib.h>
/**
* 如下4种形式都可以称为主函数, 其中:
* 第一种是标准main函数, 具有argc和argv两个参数, 返回类型为int
* 第二种仅具有返回类型, 不具备参数列表
* 第三种返回类型为空, 不具备参数列表
* 第四种没有返回类型, 不具备参数列表, 但编译时会自动设置返回类型为int
*/
//int main(int argc, char* argv[])
//int main()
//void main()
main()
{
printf("Hello World\n");
system("pause");
return 0;
}
一个函数的函数名既是该函数的代表,也是一个变量。由于函数名变量通常用来把函数的处理结果数据带回给调用函数,即递归调用,所以一般把函数名变量称为返回值。 函数可以有返回值,也可以没有返回值。一般情况下不要省略返回值的类型,C语言默认返回类型为int,C++默认为void,如果省略了,就会按照默认返回值处理。
展开全部
因为你在最后没有写一个返回值的语句。
你可以这样写:(在Main过程里)
string a;
a = "hello world";
console.writeline(a);
return a;
你试一下吧
我也是C语言的新手
你可以这样写:(在Main过程里)
string a;
a = "hello world";
console.writeline(a);
return a;
你试一下吧
我也是C语言的新手
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的main函数后没有括号,而且没有返回值类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询