zoukankan      html  css  js  c++  java
  • E0144"const char *" 类型的值不能用于初始化 "char *" 类型的实体的三种解决方法

    意思很明确const char* 和char *类型不匹配

    解决的方法有三种:

    第一种:在visual studio中,在项目上右键,在弹出菜单上选择“属性”,选择“C/C++”,然后在“语言”中,把“符合模式”改为“否”就好了。

    第二种:使用强制类型转换:

    //有问题代码char *str2 = "hello world";
    //正确的代码char *str2 = (char *)"hello world";

    第三种:先用字符数组进行存储,然后再使用指针:

    char str1[] = "hello world";
    char* str2 = str1;
  • 相关阅读:
    es6 类
    set/ weakset/ map/ weakmap
    async/await
    生成函数
    数组的操作
    解决异步(重点promise函数)
    迭代器
    遍历
    symbol 数据类型
    es6.代理 proxy
  • 原文地址:https://www.cnblogs.com/xiximayou/p/12121287.html
Copyright © 2011-2022 走看看