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 *'的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 前台传参数时间类型不匹配:type 'java.lang.String' to required type 'java.util.Date' for property 'createDate'

    springMVC action接收参数: org.springframework.validation.BindException: org.springframework.validation.B ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 解决BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type XXX, but was actually of type XXX问题

    Java新手,困扰了一下午. 发布时总是报这样一个错误. org.springframework.beans.factory.BeanCreationException: Error creating ...

  8. 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] ...

  9. 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 = ...

随机推荐

  1. puppet工作原理及部署redis主从篇

    一.简介 1.国际惯例什么是puppet puppet是一种Linux.Unix.windows平台的集中配置管理系统,使用自有的puppet描述语言,可管理配置文件.用户.cron任务.软件包.系统 ...

  2. 利用RabbitMQ实现分布式事务

    实现要点:1.构建本地消息表及定时任务,确保消息可靠发送:2.RabbitMQ可靠消费:3.redis保证幂等 两个服务:订单服务和消息服务 订单服务消息可靠发送 使用springboot构建项目,相 ...

  3. WCF header 域

    [OperationContract] [WebInvoke(UriTemplate = "poststr1")] public string poststr1(csinfo cs ...

  4. ubuntu18.04 安装android studio

    首先从官网下载android studio:Android Studio (安装前应先安装JDK环境) 得到android-studio-ide-191.5977832-linux.tar.gz 在安 ...

  5. python之约束、加密及logging模块

    一.什么是约束? 在生活中的约束大概就是有什么原因,导致你不能做这件事情了,称之为约束.而在python中的约束是在当多个类中,都需要使用某些方法时,需要人为抛出异常或使用基类+异常处理来进行约束 c ...

  6. OF框架使用指导系列索引

    一.项目搭建指导 [OF框架]搭建标准工作环境 [OF框架]使用OF框架创建应用项目 [OF框架]在Visual Studio中启用Docker支持,编译生成,并在容器运行项目 [OF框架]在Visu ...

  7. springboot 配置 中查找application.properties中对应的数据,添加对应的prefix前缀

    @ConditionalOnProperty(prefix = "spring.redis", name = "enabled", havingValue = ...

  8. Java对象内存分配原理与布局

    当一个对象被创建了,那在JVM中是如何的从一个对象不存在到存到,然后将对象存放在什么地方呢?这次主要来探讨一下Java对象创建的过程. new关键字创建对象的3个步骤: 1.在堆内存中创建出对象的实例 ...

  9. Linux网络编程综合运用之MiniFtp实现(三)

    前面已经对FTP相关的一些概念有了基本的认识,接下来就要进入代码编写阶段了,也是非常兴奋的阶段,在开启这个它之前先对项目需求进行一个梳理,对其我们要实现的FTP服务器是一个什么样子. ftp命令列表 ...

  10. erase & remove_if 合用

    words_.erase( remove_if( words_.begin(), words_.end(), [&](const entry& e) { return (e.type ...