#include <stdio.h>
#include <string.h>
char c[5];
int main(void)
{
char a[] = "linux";
char d[] = {'l', 'i', 'n', 'u', 'x', '\0'};
char b[5];
printf("a[] = %d\n", sizeof(a));
printf("a[] = %d\n", strlen(a));
printf("b[] = %d\n", sizeof(b));
printf("b[] = %d\n", strlen(b));
printf("c[] = %d\n", sizeof(c));
printf("c[] = %d\n", strlen(c));
printf("d[] = %d\n", sizeof(d));
printf("d[] = %d\n", strlen(d));
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char a[9];
int main(void)
{
char b[9];
int i;
char *p = (char *)malloc(10*sizeof(char));
if(NULL == p){
printf("malloc erro\n");
return 0;
}
char *pm = p;
char *pa = a;
char *pb = b;
for(i = 0; i < 6; i++){
*p++ = 'i';
(*pa) = 'i';
*pb = 'i';
pa++;
pb++;
}
*pa = '\0';
*pb = '\0';
*p = '\0';
printf("a[] = %s\n", a);
printf("b[] = %s\n", b);
printf("pm = %s\n", pm);
free(pm);
return 0;
}