优化了命名

This commit is contained in:
lzy
2024-04-28 13:10:56 +08:00
parent d75a518c0f
commit ba9f2e37a7
155 changed files with 0 additions and 0 deletions

54
C06-指针/chararr.c Normal file
View File

@@ -0,0 +1,54 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char *str = "hello";
printf("%d %d\n", sizeof(str), strlen(str));
// out: 8 5
//(F) strcpy(str, "world");
// 这里企图把 "world" 覆盖 "hello"这个串常量
str = "world";
puts(str);
// char str[] = "hello";
// printf("%d %d\n", sizeof(str), strlen(str));
// out :6 5
#if 0
char str[] = "hello";
// str[6]
//(F) str = "world";
strcpy(str, "world");
puts(str);
#endif
#if 0
char str[] = "I love china!";
char *p = str + 7;
puts(str);
puts(p);
// I love china!
// china!
#endif
exit(0);
}