本文共 728 字,大约阅读时间需要 2 分钟。
这段代码中,有一个注意的地方,scanf("%d",&(pArray[i].age)), 意思就是往这个地址中赋值。
#define _CRT_SECURE_NO_WARNINGS #include#include #include typedef struct Teacher{ char name[64]; int age ; int id;}Teacher;void printTeacher(Teacher *array, int num){ int i = 0; for (i=0; i array[j].age) { tmp = array[i]; //=号操作 赋值操作 array[i] = array[j]; array[j] = tmp; } } }}// 结构体数组 3 输入老师的年龄,排序void main22(){ int i = 0; Teacher Array[3]; //在stack 分配内存(临时区) int num = 3; for (i=0; i
附加一段小代码,更加具体演示scanf的用法
#include#include #define high 2#define row 3#define col 4 int main(){ int i; printf("please enter the number of i\n"); scanf("%d",&i); printf("i : %d", i); }
转载地址:http://kqzmi.baihongyu.com/