顯示具有 結構 標籤的文章。 顯示所有文章
顯示具有 結構 標籤的文章。 顯示所有文章

2009年8月15日 星期六

C/C++筆記-struct結構用法

struct animal { //結構名稱可省略,但就不能再建此結構
  char name[10];
  int sex;
}dog; //變數名稱可省略,之後再另行建立

宣告 => struct animal cat,pig[5];
指標宣告 => struct animal *kitty=cat;

C++予許省略struct保留字

C/C++筆記-結構傳遞與回傳結構

int cmp(struct animal s1, struct animal s2)
{
  return s1.sex == s2.sex;
}

struct animal getinfo(void)
{
  struct anumal temp;
  gets(temp.name);
  scanf("%d",&temp.sex);
  return temp;
}
##ShowAll##
/