JAVA就是C++包装加上垃圾回收机制和JVM
结构体
每个学生都有age score name....
int age;
int score;
char name[100]; // c语言里面的字符串一般都存放在字符数组中.
struct Student
{
int age;
float score;
char sex;
};
int main(void)
{
struct Student st={80,55.6f,'F' };
}
函数的指针
#include <stdio.h>
struct Student
{
int age;
float score;
char sex;
int(*pf)(int x, int y);
};
//子函数
int add(int x, int y){
return x+y;
}
int main(void)
{
struct Student st={80,55.6f,'F' };
st.pf = add;
printf("学生年龄%d\n",st.age);
printf("result=%d\n" ,st.pf(3,5));
system("pause");
}
#include <stdio.h>
//子函数
int add(int x, int y){
return x+y;
}
main()
{
//定义一个函数的指针。申明一个变量 用来存放函数的首地址 pf
int(*pf)(int x, int y); //函数的指针 函数在内存中的地址
pf = add;
printf("result=%d\n", pf(3,5));
system("pause");
}