1.结构体做函数参数值传递 示例: package main //必须有个main包 import "fmt" //定义一个结构体类型 type Student struct { id int name string sex byte //字符类型 age int addr string } func test01(s Student) { s.id = 666 fmt.Println("test01: ", s) } func main() { s := Stud…
1.指针做函数参数 示例: package main //必须有个main包 import "fmt" func swap(a, b int) { a, b = b, a fmt.Printf("swap: a = %d, b = %d\n", a, b) } func main() { a, b := 10, 20 //通过一个函数交换a和b的内容 swap(a, b) //变量本身传递,值传递(站在变量角度) fmt.Printf("main: a =…
定义一个数组指针,指向二维数组: int a[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}}; int (*p)[4];//定义二维指针数组 p=a;//指向二维数组,数组指针等同于二维数组名 #include<stdio.h> int main() { int a[3][4]={{1,2,3,4},{5,6,7,8},{9,10,11,12}}; int (*p)[4];//定义二维指针数组 p=a;//指向二维数组 for(int i=0;i<3;i…
# include <stdio.h> # include <stdlib.h> # include <string.h> # include <malloc.h> //创建一个结构体 typedef struct programmer { int salary; int experience; ]; } Programmer; void OneyearLater(Programmer *); int main () { Programmer p = {,…
#include<stdio.h> #include<stdlib.h> #include<string.h> int Funcadd(int a, int b) { return a + b; } int Funcplus(int a, int b) { return a - b; } int Funcmul(int a, int b) { return a * b; } int Funcdiv(int a, int b) { return a / b; } type…