摘要:// a是一个全局变量,静态变量 int a; void test() { // b是一个局部变量,自动变量 int b = 0; b++; // c是一个局部变量,静态变量 static int c = 0; c++; printf("b=%d, c=%d\n", b, c); } int main(int a...
阅读全文
摘要:#include #include // strlen void test() { // 测量字符串常量的字符长度(不包括\0这个字符) int len = strlen("李某某"); //printf("%d\n", len); // 测量字符串变量的字符长度 char s[] = "lmj"; //printf("%d\...
阅读全文
摘要:#include "one.h" #include "two.h" int main(int argc, const char * argv[]) { one(); two(); return 0; }
阅读全文
摘要:// 字符串的定义和初始化 void test() { // "mj" char s[] = {'m', 'j', '\0'}; // 字符串"mj" char s1[3] = {'m', 'j', '\0'}; // 字符串"mj" char s2[3] = {'m', 'j'}; // 并不是正规的字符串 char s...
阅读全文
摘要:指针的基本声明: void test() { char a; // a = 10; 直接引用 // 定义了一个指针变量b,而且b只能指向char类型的变量 char *b; // 让指针变量b指向a b = &a; // 这里的*b代表:访问b值对应的存储空间(也就是变量a的存储空间) // 相当于
阅读全文
摘要:#include int sum(int a, int b) { int c = a + b; printf("%d + %d = %d\n", a, b, c); return c; } int minus(int a, int b) { return a - b; } int mul(int a, int b) { ...
阅读全文
摘要:#include #define NUM -1 int main(int argc, const char * argv[]) { #if NUM > 0 printf("NUM大于0"); #elif NUM == 0 printf("NUM等于0"); #else printf("NUM小于0"); #endif return...
阅读全文
摘要:#include // 数组的定义和存储 void test1() { int ages[5]; // 64bit环境下占用4*5=20个字节 // 计算数组占据的存储空间 // size_t size = sizeof(ages); //printf("ages占据的字节:%d", size); // 查看数组的地址 ...
阅读全文
摘要:#include // NUM叫做宏名 // 6是用来替换宏名的字符串 #define NUM 6 #define mul(a, b) ((a)*(b)) void test() { // 双引号中的NUM并不会被替换为6 char *s = "NUMBER"; int a[NUM] = {1,2,3,4,5,6}; ...
阅读全文
摘要:#include char * test() { return "itcast"; } int main(int argc, const char * argv[]) { printf("%s", test()); return 0; }
阅读全文
摘要:#include void test1() { // 1.提示用户输入数据 printf("请输入一个整数:"); // 2.接收用户输入的数据 int a; // &a代表变量a的地址 // 输入完毕后敲回车 scanf("%d", &a); // 3.计算a的平方 printf("%d的平方为:%...
阅读全文
摘要:#include int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); printf("My age is %d\n", 26); // My age is 26,height is...
阅读全文