摘要:
1 #include <stdio.h> 2 #include <string.h> 3 4 int main(){ 5 char str1[12] = "Hello"; 6 char str2[12] = "World"; 7 char str3[12]; 8 int len; 9 strcpy( 阅读全文
posted @ 2022-10-08 16:30
Morning枫
阅读(31)
评论(0)
推荐(0)
摘要:
这种情况下系统会默认加\0 1 #include <stdio.h> 2 #include <string.h> 3 4 void main(){ 5 char greenting[] = "Hello"; 6 int i; 7 int len = strlen(greenting); 8 prin 阅读全文
posted @ 2022-10-08 15:23
Morning枫
阅读(38)
评论(0)
推荐(0)
摘要:
注意事项: 关于第三点: 后面?的表示垃圾值或是无用值,反正不知道 关于第四点: 数组已经满了,没有空间放结束标志\0了(空间足够的时候系统会自动给你家\0),因此输出有可能是abc,也有可能是abc+一堆乱码,扩大数组即可解决 因此输出也可能是乱码。 阅读全文
posted @ 2022-10-08 14:38
Morning枫
阅读(25)
评论(0)
推荐(0)
摘要:
1. 1 #include <stdio.h> 2 3 void main(){ 4 char word[26]; 5 for (int i = 0; i < 26; i++){ 6 word[i]='A'+i; 7 } 8 9 for (int i = 0; i < 26; i++){ 10 pr 阅读全文
posted @ 2022-10-08 14:23
Morning枫
阅读(25)
评论(0)
推荐(0)
摘要:
其中,a是数组名,类型为int,[5]是大小,即a数组最多存放五个int类型的数据 1.数组名代表该数组的首地址,即a[0]的地址 2.数组的各个元素是连续分布的,如:a[0]地址为0x1123,则a[1]的地址为0x1123+int的字节数(通常是4),即0x1123+4=0x1127,其余类推即 阅读全文
posted @ 2022-10-08 14:07
Morning枫
阅读(97)
评论(0)
推荐(0)
摘要:
预处理命令: 预处理在编译前就执行了!! 快速入门小案例: 1 #include <stdio.h> 2 #if _WIN32 3 #include <windows.h> 4 #elif __linux__ 5 #include <unistd.h> 6 #endif 7 8 int main() 阅读全文
posted @ 2022-10-08 13:22
Morning枫
阅读(68)
评论(0)
推荐(0)