2018-07-11 23:32:13 8 Comments
As I know in C++ you can change the value of (char *
) variable , but I have an error.
The error is:
error C2440: '=': cannot convert from 'const char [71]' to 'char *'
before I declared a char*
variable:
char *sql;
and then I want to use it, but:
sql = "INSERT INTO person (id,name,last,age) " \
"VALUES (1, 'Paul', 'Yezh', 14); ";
On the equal sign I have this error.
Related Questions
Sponsored Content
34 Answered Questions
10 Answered Questions
[SOLVED] Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviations
- 2014-08-01 10:33:29
- gexicide
- 138546 View
- 1256 Score
- 10 Answer
- Tags: c++ performance optimization assembly compiler-optimization
16 Answered Questions
[SOLVED] Default value to a parameter while passing by reference in C++
- 2009-06-29 18:05:29
- Sony
- 106515 View
- 106 Score
- 16 Answer
- Tags: c++ pass-by-reference default-value
23 Answered Questions
[SOLVED] Image Processing: Algorithm Improvement for 'Coca-Cola Can' Recognition
- 2012-04-16 04:23:16
- Charles Menguy
- 158694 View
- 1485 Score
- 23 Answer
- Tags: c++ algorithm image-processing opencv
10 Answered Questions
[SOLVED] Why is reading lines from stdin much slower in C++ than Python?
- 2012-02-21 02:17:50
- JJC
- 223381 View
- 1619 Score
- 10 Answer
- Tags: python c++ benchmarking iostream getline
3 Answered Questions
[SOLVED] C++ getting error C2440
- 2014-08-07 15:35:20
- user3735032
- 11353 View
- 3 Score
- 3 Answer
- Tags: c++ c visual-c++
1 Answered Questions
C++03: _ui64toa_s: error C2446: ':' : no conversion from 'errno_t' to 'const char *'
- 2015-02-20 01:11:14
- user3555181
- 501 View
- -1 Score
- 1 Answer
- Tags: c++
31 Answered Questions
[SOLVED] Why is this program erroneously rejected by three C++ compilers?
- 2011-04-01 00:50:02
- James McNellis
- 310542 View
- 471 Score
- 31 Answer
- Tags: c++ visual-c++ compiler-errors clang
5 Answered Questions
[SOLVED] Float, Double, Char, C++ Errors. What is wrong?
- 2010-10-31 19:42:43
- Thomas
- 1262 View
- 1 Score
- 5 Answer
- Tags: c++ compiler-construction floating-point
4 Answered Questions
[SOLVED] How to add strings to a 2d array of char elements?
- 2011-03-27 19:16:42
- Ziaullah Bukhari
- 4247 View
- 3 Score
- 4 Answer
- Tags: c++ string visual-c++ char
1 comments
@1201ProgramAlarm 2018-07-11 23:44:51
Since character strings are constant arrays, you need to change the type of
sql
toconst char *sql
.@Fei Xiang 2018-07-11 23:45:30
Or copy the string if it needs to be modified.
@Brian 2018-07-11 23:57:50
This answer is correct. Consider also that all compiler errors are well documented online. See here for a clear and easy explanation of the C2440 error. Always check documentation.