| |

VerySource

 Forgot password?
 Register
Search
View: 1767|Reply: 12

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

[Copy link]

4

Threads

16

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-22 21:20:01
| Show all posts |Read mode
As the title
Reply

Use magic Report

0

Threads

15

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-2-3 19:45:01
| Show all posts
Reduced security as needed
Reply

Use magic Report

0

Threads

78

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-2-4 11:15:01
| Show all posts
The conversion itself is fine

But the const attribute is eliminated,
Then the corresponding access rights will be expanded,
There may be problems ~~~

but,
As long as you can be sure that the visit will not lead to illegal operations,
Basically feasible.

In addition,
If you want to cancel const,
Why bring in const?
Reply

Use magic Report

0

Threads

15

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-2-4 13:15:01
| Show all posts
Should be discouraged
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-5 12:30:01
| Show all posts
Maybe different compilers have different processing, it is recommended to write a small program to verify it * _ *
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-10 11:15:01
| Show all posts
The conversion itself is fine

But security is reduced
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-3-21 18:45:01
| Show all posts
Better not to do this conversion
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 France

Post time: 2020-3-22 12:00:02
| Show all posts
C / C ++ prohibits this conversion.
Because of this, you can modify the const content.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-27 21:45:01
| Show all posts
Maybe it's because the floor is free.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-1 15:30:01
| Show all posts
Syntactically speaking, no problem, but the security is reduced, and problems may occur. If used with references, it cannot be forced to convert. The main problem is the assignment of references and ordinary assignment (copying).
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