随笔分类 - c/c++
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; // 打开文件前,必须定义FILE*型指针变量 char file[128]; printf("please input the file: "); scanf("%s", file); fp = fo
阅读全文
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; // 打开文件前,必须定义FILE*型指针变量。 char file[128]; printf("please input the filename: "); scanf("%s", file); //
阅读全文
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; //打开文件时,必须要提前在函数中定义FILE*型指针变量, 然后将fopen函数返回的FILE型指针对象赋值给定义的指针变量,就可以通过该变量来修改文件了 fp = fopen("a.txt","r"
阅读全文
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; char filename[128]; printf("filename: "); scanf("%s", filename); fp = fopen(filename, "r"); if(fp !=
阅读全文
摘要:1、 #include <stdio.h> int main(void) { FILE *fp; char filename[128]; printf("filename: "); scanf("%s", filename); fp = fopen(filename, "r"); if(fp !=
阅读全文
摘要:1、 #include <stdio.h> #include <math.h> #define sqr(x) ((x) * (x)) typedef struct{ double x; double y; }Point; typedef struct{ Point pt; double fuel;
阅读全文
摘要:c语言中用结构体表示点的坐标,并计算两点之间的距离 1、 #include <stdio.h> #include <math.h> #define sqr(x) ((x) * (x)) typedef struct{ double x; double y; }Point; double dist(P
阅读全文
摘要:1、 1.1 #include <stdio.h> #include <string.h> #define NUMBER 5 #define NAME_LEN 64 typedef struct{ char name[NAME_LEN]; int height; float weight; long
阅读全文
摘要:c语言中的结构体数组(数组元素为结构体)。 1、 #include <stdio.h> #include <string.h> #define NUMBER 5 #define NAME_LEN 64 typedef struct{ char name[NAME_LEN]; int height;
阅读全文
摘要:1、 #include <stdio.h> typedef struct{ int x; long y; double z; }Assign; Assign fun(int a, long b, double c) { Assign tmp; tmp.x = a; tmp.y = b; tmp.z
阅读全文
摘要:1、 #include <stdio.h> #define NAME_LEN 64 typedef struct student{ char name[NAME_LEN]; int height; float weight; long schols; }Student; void judg(Stud
阅读全文
摘要:1、 #include <stdio.h> struct xyz{ int x; long y; double z; }; struct xyz fun(int a, long b, double c) //函数的返回类型为struct xyz型 { struct xyz tmp; //声明结构体对
阅读全文
摘要:typedef的作用是对数据类型进行同义声明。 1、 #include <stdio.h> #define NAME_LEN 64 typedef struct student{ //结构的类型名是struct student, 此处使用typedef为类型名strucnt student声明了St
阅读全文
摘要:c语言中将结构体对象指针作为函数的参数实现对结构体成员的修改。 1、 #include <stdio.h> #define NAME_LEN 64 struct student{ char name[NAME_LEN]; int height; float weight; long schols;
阅读全文
摘要:1、 #include <stdio.h> // main函数头文件 #define NAME_LEN 64 // 对象式宏 struct student{ // 结构体声明, student是结构名, struct student是类型名, name、height、weight和schols是结构
阅读全文
摘要:c语言中结构体成员的初始化, 结构体的成员可以单独赋值,也可以进行整体的初始化来实现一次性赋值。 1、 #include <stdio.h> //main函数头文件 #define NAME_LEN 64 // 对象式宏 struct student{ //结构体声明, student为结构名, s
阅读全文
摘要:c语言中结构体对象的声明、结构体成员的赋值、结构体成员的显示、.句点运算符的应用 1、 #include <stdio.h> //main 函数头文件 #include <string.h> // 字符串处理库函数头文件 #define NAME_LEN 64 struct student{ //
阅读全文
摘要:1、 #include <stdio.h> #include <string.h> #define NUMBER 5 #define NAME_LEN 64 void swap_int(int *x, int *y) { int tmp = *x; *x = *y; *y = tmp; } void
阅读全文
摘要:1、 #include <stdio.h> #include <math.h> #define sqr(x) ((x) * (x)) typedef struct{ double x; double y; } Point; typedef struct{ Point pt; double fuel;
阅读全文
摘要:c语言中具有结构体成员的结构体。 1、 #include <stdio.h> #include <math.h> #define sqr(x) ((x) * (x)) typedef struct{ double x; double y; } Point; typedef struct{ Point
阅读全文

浙公网安备 33010602011771号