close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決 
TypePad Has the Tools

Looking for a premiere blogging service? Start your blog today on TypePad.
From our sponsors
c語言 建立10筆struct 的問題
Oct 23rd 2013, 14:49

(1) 使用 struct mydata:
11 行是以 mydata 宣告了 customer 變數
12 行應該就出錯了

12, 13 改為
struct mydata *ftp;
ftp=( struct mydata *)calloc(10,sizeof( struct mydata));

(2) 使用 typedef:
由於 C struct 要連帶 struct ,使用上很麻煩。大多會用 typedef 將 struct tagName 定義新 type。

也就是在第 3 行,加上 typedef,而 customer 成為新 type name,等義於 struct mydata。

int main(void)
{
typedef struct mydata
{
char name[25];
char Address1[30];
char Address2[30];
int order;
char type;
char risk;
} customer;
customer *ftp;
ftp=(customer*)calloc(10,sizeof(customer));
return 1;
}

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends:

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 yisoajkls 的頭像
    yisoajkls

    2016徵求年菜推薦網路訂購最紅的商家.年菜訂購?台北年菜外送餐廳推薦(年菜)?年菜.今年不想做年菜推薦,網路宅配哪一家好?

    yisoajkls 發表在 痞客邦 留言(0) 人氣()