作者bemyself (self)
看板Programming
标题[问题] 一个问题
时间Wed Jul 13 17:34:45 2011
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
1F:→ james732:C语言可以过,C++必须要转型 140.117.171.46 07/13 17:37
2F:→ james732:account[0] = (AccountPtr)malloc(....); 140.117.171.46 07/13 17:38
3F:→ bemyself:Oh, yes!! 感谢^^140.112.241.190 07/13 23:28