D
david
I am getting "warning: assignment discards qualifiers from pointer
target type" error from GCC and I know the error, but I still don't
know how to correct that.
I have a function with declaration: char* top(stack *item);
As you might see I have a stack with string elements. This function
should allow you to look at the value of the top element in stack and
it does that, but you can change it and this is not acceptable.
const char* top(stack *item); // can not change the pointer
const char* const top(stack *item); or const char* top(stack *item)
const; // can not change pointer nor data it points to, but I think I
am going too much in C++ here and I get a lot of errors. I think C
does not support that, some time ago it did not even support such
thing as const.
Any ideas how it should look correctly? Or C still has a weak
implantation of constants?
david
target type" error from GCC and I know the error, but I still don't
know how to correct that.
I have a function with declaration: char* top(stack *item);
As you might see I have a stack with string elements. This function
should allow you to look at the value of the top element in stack and
it does that, but you can change it and this is not acceptable.
const char* top(stack *item); // can not change the pointer
const char* const top(stack *item); or const char* top(stack *item)
const; // can not change pointer nor data it points to, but I think I
am going too much in C++ here and I get a lot of errors. I think C
does not support that, some time ago it did not even support such
thing as const.
Any ideas how it should look correctly? Or C still has a weak
implantation of constants?
david