void getMemory(char** p, int num)
{
*p = (char*)malloc(num);
char str[10];
//str = 'a'; 错误
return ;
}
#define SQ(a) ( (a)*(a) )
int main()
{
/* 1 */
char* ptr = NULL;
getMemory(&ptr,100); //ok
/* 2 */
int a = 5;
int b = SQ(a++);
std::cout << a << " " << b <
/* 3 */
strcpy(p,"hello"); //加结尾符
int ii = sizeof(p); //4
int jj = strlen(p); //5
/* 5 */
unsigned char AAA[MAX];
unsigned char i ; //unsigned最大可为255,256==0 ,
//为char型最大为254, 255时为-1
for(i = 0 ; i <= MAX ; i++)
{
AAA[i] = i ;
}
}
阅读(625) | 评论(0) | 转发(0) |