warning: ISO C++ forbids converting a string constant to 'char*'
第1种字符串赋值方式:
char * fileName="./2017-09-02-10-34-10.xml";//这一种字符串赋值方式已经被ISO禁止了
第2种字符串赋值方式:
char str[] ="./2017-09-02-10-34-10.xml";
char *fileName=str;
第3种字符串赋值方式:
char fileName[] ={"./2017-09-02-10-34-10.xml"};//有无大括号都可以
warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
解决办法:采用第2或3种字符串赋值方式
int main(int argc, char *argv[])
{
char str[] = ""; //先把C++中的string常量复制给C语言形式的字符串变量,再将str赋值给char*形式的C语言字符串。
argv[] = str;
}
warning: ISO C++ forbids converting a string constant to 'char*'的更多相关文章
- warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
在C++中, char* p = "abc"; // valid in C, invalid in C++ 会跳出警告:warning: ISO C++ forbids conve ...
- warning: deprecated conversion from string constant to 'char*
warning: deprecated conversion from string constant to 'char* #include<iostream> using namespa ...
- deprecated conversion from string constant to ‘char*’
deprecated conversion from string constant to ‘char*’ #include <iostream> using namespace std; ...
- warning:deprecated conversion from string constant to 'char *' 解决方案
#include <iostream> using namespace std; int fuc(char *a) { cout << a << endl; } i ...
- warning:deprecated conversion from string constant to 'char *'
warning:deprecated conversion from string constant to 'char *' 解决方式 #include <iostream> using ...
- warning:ISO C90 forbids mixed declarations and code
warning:ISO C90 forbids mixed declarations and code 变量定义之前不论什么一条非变量定义的语句(重视:语句是会带分号的)都会引起这个警告! 将非变量的 ...
- expected declaration specifiers or '...' before string constant
/work/platform_bus_dev_drv/led_dev.c:52: error: expected declaration specifiers or '...' before stri ...
- ISO C90 forbids mixed declarations and code 警告
编译的时候经常会遇到 ISO C90 forbids mixed declarations and code 警告百度了一下,知道是如下原因 : 变量定义之前任何一条非变量定义的语句(注意:语句是 ...
- qt ISO C++ forbids declaration of 'XXXX' with no type
error: ISO C++ forbids declaration of 'XXXX' with no type 出现这个错误,一般是由于两个CPP相互都相互包含了对方的头文件造成的,比如: 当 ...
随机推荐
- 试图加载格式不正确的程序 .net
一般是dll位数不对,重新编译一下即可
- Java并发编程:Java创建线程的三种方式
目录 引言 创建线程的三种方式 一.继承Thread类 二.实现Runnable接口 三.使用Callable和Future创建线程 三种方式的对比 引言 在日常开发工作中,多线程开发可以说是必备技能 ...
- iomanip的作用 C++
c++程序里面经常见到下面的头文件 #include <iomanip> 这里面iomanip的作用比较多: 主要是对cin,cout之类的一些操纵运算子,比如setfill,setw,s ...
- 教你分分钟搞定Python之Flask框架
用最短的时间开发一个数据操作接口,Python是王道! 一.安装pip .首先检查linux有没有安装python-pip包,终端执行 pip -V [root@ network-scripts]# ...
- css居中的方法
- CSS总结div中的内容垂直居中的五种方法
一.行高(line-height)法 如果要垂直居中的只有一行或几个文字,那它的制作最为简单,只要让文字的行高和容器的高度相同即可,比如: p { height:30px; line-height:3 ...
- 怎么在ReactNative里面使用Typescript
今天来搞一搞怎么搭建一个可以使用Typescript的ReactNative环境好吧,一句废话不多说,直接开始好吧 1.全局安装create-react-native-app yarn global ...
- CSS盒模型的介绍
CSS盒模型的概念与分类 CSS盒模型就是一个盒子,封装周围的HTML元素,它包括内容content.边框border.内边距padding.外边距margin. CSS盒模型分为标准模型和 ...
- Spark机器学习——模型选择与参数调优之交叉验证
spark 模型选择与超参调优 机器学习可以简单的归纳为 通过数据训练y = f(x) 的过程,因此定义完训练模型之后,就需要考虑如何选择最终我们认为最优的模型. 如何选择最优的模型,就是本篇的主要内 ...
- Ansible--常用模块使用(2)
Ansible常用模块 cron 模块 用途:cron模块⽤于设置定时任务,也⽤于管理定时任务中的环境变量使用方法: [root@ansible ~]# ansible-doc -s cron - n ...