1. sizeof()和strlen()函数
sizeof常见标准用法:
(1)
char buff[6];
strncpy(buff, argv[1], sizeof(buff));
(2)
int array[] = { 3, 1, 4, 1, 5, 9 };
unsigned int array_size = sizeof(array) / sizeof(array[0]);
(3)
typedef struct data_type {
int age;
char name[20];
} data;
data *bob;
bob = (data*) malloc( sizeof(data) );
if( bob != NULL ) {
bob->age = 22;
strcpy( bob->name, "Robert" );
printf( "%s is %d years old\n", bob-&g......
阅读全文