#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void main01() {
char buf1[128] = {'a', 'o', 'e'};
printf("%s\n", buf1);
char buf2[] = { 'a', 'o', 'e' };
printf("sizeof(buf2):%d, buf2 is %s\n", sizeof(buf2), buf2);
char buf3[] = { 'a', 'o', 'e', '\0'};
printf("sizeof(buf3):%d, buf3 is %s\n", sizeof(buf3), buf3);
char buf4[] = "aoe";
printf("sizeof(buf4):%d, buf4 is %s\n", sizeof(buf4), buf4);
printf("sizeof(\"aoe\"):%d, %s\n", sizeof("aoe"), "aoe");
system("pause");
}
void main02() {
char buf4[] = "aoe";
printf("sizeof(buf4):%d\n", sizeof(buf4));
printf("strlen(buf4):%d\n", strlen(buf4));
system("pause");
}
void main() {
char buf[] = "aoe";
for (int i = 0; i < strlen(buf); i++) {
printf("%c", buf[i]);
}
char* ptr = NULL;
ptr = buf;
for (int i = 0; i < strlen(buf); i++) {
printf("%c", *(ptr+i));
}
system("pause");
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79