Cannot initialize a variable of type 'Stu *' with an rvalue of type 'void *'
2024-08-27 10:21:41
code:
将
Stu* pStu = malloc(sizeof(Stu));
改为
Stu* pStu = (Stu*)malloc(sizeof(Stu));
code
#include <stdio.h>
#include <stdlib.h> typedef struct {
int a;
int b;
}Stu; Stu* getStu(int x, int y)
{
Stu* pStu = (Stu*)malloc(sizeof(Stu));
pStu->a = x;
pStu->b = y;
return pStu;
} int main()
{
int x = , y = ;
Stu *pStu = getStu(x, y);
printf("%d %d\n", pStu->a, pStu->b);
free(pStu);
return ;
}
输出
Program ended with exit code:
https://blog.csdn.net/weixin_34221332/article/details/86981433
最新文章
- MVC 框架搭建
- EXTJS 动态改变Gird 列值
- Java 7 的7个新特性
- elasticsearch2.2 集群搭建各种坑
- NSRangeFromString 测试
- Selenium如何使用自定义的Firefox配置文件?
- Sourcetree add Submodule
- HTML5之 WebWorkers
- Log4Net 使用总结
- 一个磁盘I/O故障导致的AlwaysOn FailOver 过程梳理和分析
- sql 中 and 和 or的坑
- (12)SecureCRT中文乱码问题
- Kubernetes节点维护
- 整型 布尔值 字符串 for循环
- python自动化测试入门篇-postman
- 转";container of()函数简介";链接地址
- HDU 1014 G题
- 【整理】Git相关资料
- jQuery.event详细解析
- CNN细节
热门文章
- Spring Cloud Alibaba学习笔记(13) - Spring Cloud Stream的监控与异常处理
- RuntimeError: Model class users.models.UserProfile doesn&#39;t declare an explicit app_label and isn&#39;t in an application in INSTALLED_APPS.
- VC 中的ATL ActiveX 和 MFC ActiveX 有什么区别
- Eva 剧情解析
- MP4数据封装格式
- JSONObject和URL以及HttpURLConnection的使用
- arm的基本介绍
- flask之蓝图BulePrint使用
- Mysql之表的查询
- [dev][ipsec][distributed] strongswan如何做热迁移/高可用/High Availability