c语言修正一下语法
#include <stdio.h>
#include <windows.h>
//#include "Test.h"
struct test
{
int a;
int b;
int test1( int a,int b )
{
return a + b;
}
};
int main()
{
test s;
s.test1(3,4);
printf("%d ",s.test1);
return 0;
}
想输出a+b的值。应该怎么改??
首先,你的程序不是c语言的,是C++的(C和C++是二种不同的语言),C不支持类的
其次,你对函数不是很理解 ,函数返回值不能记忆的
两个方法
1。直接用
test s;
printf("%d
",s.test1(3,4)); //输出
2。用临时变量
test s;
int t=s.test1(3,4); //得到结果
printf("%d
",t); //输出结果
热门标签: