摘要:
可以用typedef声明新的类型名来代替已有的类型名。 实例1: #include<stdio.h> #include<iostream> typedef struct { char* name; int age; }STUDENT; int main() { STUDENT stu; stu.na 阅读全文
posted @ 2020-01-01 16:44
西西嘛呦
阅读(689)
评论(0)
推荐(0)
摘要:
在c语言中,一般有两种方式来创建字符串 //第一种,利用字符指针 char* p = "hello"; //第二种:利用字符数组 char str[] = "hello"; 那么,它们之间有什么区别呢?以例子说明: #include<stdio.h> #include<iostream> char* 阅读全文
posted @ 2020-01-01 16:19
西西嘛呦
阅读(4793)
评论(0)
推荐(1)
摘要:
#include<stdio.h> #include<iostream>#define CORRECT "myfirst" int main() { char str[10]; int func(char* str1, char* str2); printf("输出你最喜欢的:\n"); scanf 阅读全文
posted @ 2020-01-01 15:24
西西嘛呦
阅读(327)
评论(0)
推荐(0)
摘要:
#include<typeinfo> using std::cout; int main() { int i; cout << typeid(i).name(); //输出结果为int return 0; } 需要引入头文件:#include<typeinfo> 阅读全文
posted @ 2020-01-01 15:13
西西嘛呦
阅读(6296)
评论(0)
推荐(0)
摘要:
#include<stdio.h> #include<iostream> int main() { char* str[10]; printf("请输入:\n"); scanf("%s\n", str); printf("您的输入是:%s\n",str); system("pause"); retu 阅读全文
posted @ 2020-01-01 15:12
西西嘛呦
阅读(3125)
评论(0)
推荐(0)
摘要:
1.##:用于拼接操作 实例: #include<stdio.h> #include<iostream> #define CONCAT(parm1,parm2) (parm1##parm2) int main() { int res = CONCAT(1, 2); printf("%d\n", re 阅读全文
posted @ 2020-01-01 15:06
西西嘛呦
阅读(728)
评论(0)
推荐(0)
摘要:
1.带参数的宏定义中,宏名和新参表之间不能有空格, 2.在带参数的宏定义中,形参参数不分配内存单元,因此不必作类型定义。而宏调用中的实参有具体值,要用它去代换形参,因此必须作类型说明。 #include<stdio.h> #include<iostream> #define MAX(a,b) (a> 阅读全文
posted @ 2020-01-01 13:51
西西嘛呦
阅读(4546)
评论(0)
推荐(0)
摘要:
转自:https://www.cnblogs.com/luanch/p/3393593.html C语言不用循环不用递归打印0-999的小程序,你看懂了吗? #include<stdio.h> #define A(x) x;x;x;x;x;x;x;x;x;x; void main(){ int n 阅读全文
posted @ 2020-01-01 11:50
西西嘛呦
阅读(290)
评论(0)
推荐(0)
摘要:
宏定义只是简单的字符串代换,是在预处理完成的,而typedef是在编译时处理的,它不是作简单的代换,而是对类型说明符进行重新命令。被命名的标识符具有类型定义说明的功能。 #include<stdio.h> #include<iostream> #define PIN1 char* typedef c 阅读全文
posted @ 2020-01-01 11:42
西西嘛呦
阅读(366)
评论(0)
推荐(0)
摘要:
//定义一个指针变量 int *p; (1)指针可以进行加减一个整数:p++、p--、p+i、p-i、p+=i、p-=i等 (2)将一个变量的地址赋值给指针:int a = 1;p = &a; (3)将数组首元素的地址赋值给指针:int array[3] = {1,2,3};p = array; ( 阅读全文
posted @ 2020-01-01 11:17
西西嘛呦
阅读(1036)
评论(0)
推荐(0)
摘要:
定义 含义 int i; 定义整型变量i int* p; p为指向整型数据的指针变量 int a[n]; 定义整型数组a,它有n个元素 int* p[n]; 定义指针数组p,它由n个指向整型数据的指针元素构成 int (*p)[n]; p为指向含n个元素的一维数组的指针变量 int f(); f为返 阅读全文
posted @ 2020-01-01 10:57
西西嘛呦
阅读(808)
评论(0)
推荐(0)
摘要:
#include<stdio.h> #include<iostream> int main(int argc,char *argv[]) { printf("参数的个数是(包括第0个当前可执行文件的名字):%d\n", argc); //参数列表,字符串指针 while (*argv) { puts 阅读全文
posted @ 2020-01-01 10:48
西西嘛呦
阅读(1347)
评论(0)
推荐(0)