所有新聞群組討論區列表 風禹科技驗證有限公司 Web News Reader

目前新聞群組:tw.bbs.comp.language

項目 內容
發文者 self
日期 2011/7/13 下午 05:34:50
標題 [問題] 一個問題
檔頭
220 151840 <56gEkR$8Tb@ptt.cc> article
Path: netnews!ctu-gate!news.nctu.edu.tw!news.ntu.edu.tw!ptt
From: bemyself.bbs@ptt.cc (self)
Newsgroups: tw.bbs.comp.language
Subject: [問題] 一個問題
Date: 13 Jul 2011 09:34:50 +0000 (UTC)
Organization: 批踢踢實業
Lines: 25
Message-ID: <56gEkR$8Tb@ptt.cc>
NNTP-Posting-Host: 140.112.172.1
Mime-Version: 1.0
Content-Type: text/plain; charset=big5
Content-Transfer-Encoding: 8bit
X-Trace: news.ntu.edu.tw 1310550302 45735 140.112.172.1 (13 Jul 2011 09:45:02 GMT)
X-Complaints-To: usenet@news.ntu.edu.tw
NNTP-Posting-Date: Wed, 13 Jul 2011 09:45:02 +0000 (UTC)
X-Filename: Programming/M.1310549691.A.A5A
X-Auth-From: 140.112.241.190
Xref: netnews tw.bbs.comp.language:151840
內文
struct account{
    char *account;
    char *password;
};
typedef struct account Account;
typedef Account *AccountPtr;

AccountPtr account[10];

account[0] = malloc(sizeof(Account));

為何compile時它說"invalid conversion from `void*' to `Account*' "呢?

我知道用malloc會回傳void沒錯

但教科書裡這樣寫也可以過  而且這樣assign好像也是可以的?

謝謝

--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.241.190
→ james732:C語言可以過,C++必須要轉型              140.117.171.46 07/13 17:37
→ james732:account[0] = (AccountPtr)malloc(....);  140.117.171.46 07/13 17:38

基本條件

.Net 原始碼 | ASP.NET News Reader Beta 0.2.9

請參閱

個人資料 | 發表新文章 | 回覆 | 回信 | 轉寄 | 同標題 | 搜尋 | 列印 預覽 直接

重要訊息通知

2007/06/21 由於微軟新聞伺服器移除多數新聞群組 (newsgroup),目前遭移除之群組暫時改為隱藏純瀏覽,若狀況已定案時,將會將隱藏中的群組重新調整。[討論]