warning:deprecated conversion from string constant to 'char *' 解决方式 #include <iostream> using namespace std; int fuc(char *a) { cout << a << endl; } int main() { fuc("hello"); } Linux 环境下当GCC版本号比較高时,编译代码可能出现的问题. 主要原因是: char * 指…
#include <iostream> using namespace std; int fuc(char *a) { cout << a << endl; } int main() { fuc("hello"); } Linux 环境下当GCC版本比较高时,编译代码可能出现的问题 问题是这样产生的,先看这个函数原型: void someFunc(char *someStr); 再看这个函数调用: someFunc("I'm a strin…
warning: deprecated conversion from string constant to 'char* #include<iostream> using namespace std; class Student { private: int age; char*name; public: Student(int m, char *n) { age=m;name=n; } Student() { age=;name="unnamed"; } ~ Stude…
deprecated conversion from string constant to ‘char*’ #include <iostream> using namespace std; int fuc(char *a) { cout << a << endl; } int main() { fuc("hello"); } Linux 环境下当GCC版本比较高时,编译代码可能出现的问题 问题是这样产生的,先看这个函数原型: 1 void someF…
一个低级但是不好定位的编译错误,常见的问题是: 1. 语句的 { 括号不匹配. 2. 缺少 : , 特别是类的定义或声明,枚举的定义. 3. 变量名或函数名使用了保留字.…
运行代码为 /* * main.cpp * * Created on: Apr 7, 2016 * Author: lizhen */ #include <iostream> //#include "MySqrt.h" #include <math.h> #include <vector> #include <typeinfo> #include <exception> #include <stdexcept> #…
在C++中, char* p = "abc"; // valid in C, invalid in C++ 会跳出警告:warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 改成下面会通过warning char* p = (char*)"abc"; // OK 或者改成下面: char const *p = "abc"; // OK…
第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"};//有无大括号都可以 warn…
/work/platform_bus_dev_drv/led_dev.c:52: error: expected declaration specifiers or '...' before string constant /work/platform_bus_dev_drv/led_dev.c:52: warning: data definition has no type or storage class /work/platform_bus_dev_drv/led_dev.c:52: wa…
Question: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "…