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. iOS - App上架流程(复习+已用xcode8)

    一.前言: 今天又要上架一款APP,顺便来复习一下APP上架流程 下面就来详细讲解一下具体流程步骤. 二.准备: 一个已付费的开发者账号(账号类型分为个人(Individual).公司(Company ...

  2. Java 之 递归

    一.概述 递归:指在当前方法内调用自己的现象. 递归的分类: 递归分为两种,直接递归和简介递归 直接递归称为方法自身调用自己 间接递归可以 A 方法调用 B 方法,B 方法调用 C 方法,C 方法调用 ...

  3. redis入门初学知识

    一. Redis 介绍 Remote Dictionary Server(Redis)是一个开源的使用 ANSI C 语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value 数据库,并提 ...

  4. Devices Tree加载流程

    DT.IMG布局 hdr zImage Ramdisk.img DT.img 其中DT.img由DTBTOOL打包所有编译生成的dtb生成:布局如下: DT header dt_entry_0 dt_ ...

  5. Django中使用geetest验证

    一.geetest的使用方法 首先需要在setting中配置好文件 GEE_TEST = { "gee_test_access_id": "37ca5631edd1e88 ...

  6. P1005 矩阵取数游戏[区间dp]

    题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的\(m*n\)的矩阵,矩阵中的每个元素\(a_{i,j}\)均为非负整数.游戏规则如下: 每次取数时须从每行各取走一个元素,共n个.经过m次后 ...

  7. 05-Docker私有仓库

    一.介绍私有仓库顾名思义,如果我们不想把docker镜像公开放到公有仓库中,只想在部门或团队内部共享docker镜像,这时私有仓库就来了. 二.私有仓库搭建与配置1.拉取私有仓库镜像,这里说明一下,私 ...

  8. mysql对子查询的优化改写

    重庆SEO:<高性能mysql第三版>提到mysql会将in子查询改写成exists查询(书中基于的mysql版本是5.1.50和5.5) 但是在5.6之后,已经优化成使用半连接查询 SE ...

  9. Object.defineProperty 相关学习

    Object.defineProperty 学习   描述: 方法直接在对象上定义一个新属性,或修改对象上的现有属性 并返回该对象.该方法允许精确地添加或修改对象上的属性: 语法: Object.de ...

  10. MyBatis模糊查询和多条件查询

    一.ISmbmsUserDao层 //根据姓名模糊查询 public List<Smbms> getUser(); //多条件查询 public List<Smbms> get ...