二捆等、代碼
#include <stdio.h>
typedef int myInt;
#define Inter int
// 一般情況下 如果要給數(shù)據(jù)類型 起一個名詞 建議用typedef, 不要define
typedef char * String;
// 宏定義僅僅是替換
#define MY_STRING char *
int main()
{
/*
int num = 10;
printf("num = %i\n",num);
myInt age = 25;
printf("age = %i\n",age);
Inter socre = 22;
printf("socre = %i\n",socre);
*/
/*
char *name = "lyh";
printf("name = %s\n",name);
String name1 = "lyh1";
printf("name1 = %s\n",name1);
MY_STRING name2 = "lyh2";
printf("name2 = %s\n",name2);
*/
String name1,name2;
name1 = "lyh";
name2 = "lyh1";
printf("name1 = %s, name2 = %s\n",name1,name2);
// char * name3,name4; // char *name; char name4;
MY_STRING name3,name4;
name3 = "lyh2";
name4 = "lyh3"; // incompatible pointer to inerger conversion assigning to char from char[5]
// 訪問了一個壞的內(nèi)存
printf("name3 = %s, name4 = %s\n",name3,name4);
return 0;
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者