close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決 
50% off Print Subscription of USA Today

Get the news delivered to your doorstep. Lock in the savings and receive USA Today for just $0.75 a day.
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
    全站熱搜
    創作者介紹
    創作者 mkmkmklal 的頭像
    mkmkmklal

    線上遊戲排行榜2013/2014,進擊的巨人線上看,candy crush saga外掛,正妹寫真三圍

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