Cannot initialize a variable of type 'Stu *' with an rvalue of type 'void *'
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
Cannot initialize a variable of type 'Stu *' with an rvalue of type 'void *'的更多相关文章
- C++之error: cannot bind non-const lvalue reference of type ‘myString&’ to an rvalue of type ‘myString’
先看代码(不想看代码可以直接看代码后的问题描述) //header.h #ifndef _HEADER_H #define _HEADER_H #define defaultSize 128 #inc ...
- Format specifies type 'int' but the argument has type 'struct node *'
/Users/Rubert/IOS/iworkspace/LineList/LineList/main.c::: Format specifies type 'int' but the argumen ...
- 前台传参数时间类型不匹配:type 'java.lang.String' to required type 'java.util.Date' for property 'createDate'
springMVC action接收参数: org.springframework.validation.BindException: org.springframework.validation.B ...
- Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'xxx': no matching editors or conversion strategy found
今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.cor ...
- How do I check if a type is a subtype OR the type of an object?
To check if a type is a subclass of another type in C#, it's easy: typeof (SubClass).IsSubclassOf(ty ...
- Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill
异常信息如下: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value ...
- 解决BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type XXX, but was actually of type XXX问题
Java新手,困扰了一下午. 发布时总是报这样一个错误. org.springframework.beans.factory.BeanCreationException: Error creating ...
- spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'
在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] ...
- swift2.0 Cannot assign a value of type '[CFString]' to a value of type '[String]'
Cannot assign a value of type '[CFString]' to a value of type '[String]' 代码示例如下: picker.mediaTypes = ...
随机推荐
- Windows终端命令行工具Cmder
在IT这一行,大部分情况下都是推荐大家使用Linux或者类Unix操作系统去编程,Linux作为一代优秀的操作系统,已经人尽皆知,在IT行业已经成为核心.有条件的大佬都选择了使用mac编程,最优秀的莫 ...
- C# Aforge设置摄像头视频属性和控制属性
修改后的代码:github 一.调用windows自身摄像头属性设置窗口 使用VideoCaptureDevice对象的DisplayPropertyPage(IntPtr parentWindow) ...
- word中快捷键查看与设定
很多时候,我们在编辑word文档的时候,为了快速方便都使用快捷键,常用的快捷键大家都知道,但是不常用的是不是就比较懵圈,本文就来告诉你怎么查看与设置word的快捷键. 我使用的word2016 第一步 ...
- JIT优化的小问题
同事问了个问题,挺有意思的,代码: public class TestJIT{ private static boolean sss; public static void main(String[] ...
- 透过CountDownLatch窥探AQS
本文来自公众号“Kahuna”,可搜索Alitaba119,欢迎关注,转载请注明出处,非常感谢 “ A synchronization aid that allows one or more thre ...
- G1垃圾收集器深度理论讲解【纯理论】
在上三次中对于G1官方解读之后,接下来还得回到G1的理论化知识的了解阶段..确实G1是概念比较复杂,而且它也是未来JDK的垃圾回收的主流,所以花再多的时间在这上面也是值得的,先来回顾一下上次过过的理论 ...
- archlinux 蓝牙耳机没有声音
前提 蓝牙已开,并且连接成功,但是蓝牙耳机没有声音. 安装 pacman -S pulseaudio-bluetooth pulsemixer 切换设备输出为蓝牙耳机
- MySQL的索引优化,查询优化
MySQL逻辑架构 如果能在头脑中构建一幅MySQL各组件之间如何协同工作的架构图,有助于深入理解MySQL服务器.下图展示了MySQL的逻辑架构图. MySQL逻辑架构,来自:高性能MySQL My ...
- Mybatis-Generator逆向工程,简单策略
1.下载generator包 https://github.com/mybatis/generator/releases mybatis-generator-core-1.3.6.zip 官网下载即可 ...
- sql 索引的使用 转载:https://www.cnblogs.com/xiaoyangjia/p/11267191.html#mysql_performance
B-Tree索引的3个限制: 如果不是按照索引的最左列开始查找,则无法使用索引 不能跳过索引中的列.如果联合索引(a,b,c) ,如果使用条件a和c条件查询,那么只能使用索引的第一列a 如果查询中有某 ...