Link to home
Create AccountLog in
Avatar of naseeam
naseeamFlag for United States of America

asked on

How to correctly fix 'ptr to const' to 'ptr' error?

In a 'C' language program, pointer to constant is assigned to a pointer.

The compiler gives an error on this assignment because pointer to const is being assigned to a pointer.

What is the correct or best way to fix this error?  One way to fix this error is to typecast RHS of the assignment statement to pointer.  Is that the correct fix?

What might be some situations where pointer to const needs to be assigned to pointer?

Is it sloppy code to define pointer which will be assigned pointer to const?

Please provide some exampels to this issue.


Thanks!
ASKER CERTIFIED SOLUTION
Avatar of HooKooDooKu
HooKooDooKu

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of naseeam

ASKER

Perfect!   Extremely useful solution!   Very quick response!