| |

VerySource

 Forgot password?
 Register
Search
Author: likang1986

Is it a problem to cast const char * to char *?

[Copy link]

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-13 20:45:01
| Show all posts
For different compilers, the results are different.

In most compilers, this conversion is not allowed

Don't know why you want to convert like this
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-13 21:15:02
| Show all posts
This is not allowed on most compilers
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-15 19:45:01
| Show all posts
It can be converted in many cases. . .

It's just that modifying the content declared with const will cause uncertain results.
Some programs generated by the linker will cause errors in writing read-only memory.
Some programs do not make mistakes because they do not have memory protection.
Some programs automatically make read-only memory writable when modifying read-only memory. So there is no mistake.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list