M
mdh
....snip...
Since it never deals with numbers greater than 1, it avoids all
possibilities of overflow. Also works for all numerical types for
*s and *t.
thanks Chuck...that's what I like about it.
....snip...
Since it never deals with numbers greater than 1, it avoids all
possibilities of overflow. Also works for all numerical types for
*s and *t.
mdh said:int main (int argc, const char * argv[])
There's your problem. Should be:
int main(int argc, char *argv[])
instead.
Thank you Pete..
I am beginning to understand the difference in terms of "type of
memory"..(.as per RH.) ..for a char array.
Thank you Pete..
I am beginning to understand the difference in terms of "type of
memory"..(.as per RH.) ..for a char array.
In you declaration of main, you stated that argv "could be considered as"
an array of pointers (we know it is actually a char**) and that each
pointer in the array would point to a constant char. You then passed
argv[1] to a function as an argument that did not agree to treat the
character pointed to as constant. This is what your compiler is
complaining about. The const qualifier that applies to *argv[1] does
not apply to the object pointed to by parameter s of your function.
This would allow the function to legally alter *s but you said
*argv[1] (which is the same object) cannot be modified. The compiler
is pointing out the inconsistency.
If you had cast the argument to an unqualified char*, the compiler
would not complain .................snip............ It is only if your
function then attempted to modify *s that the type of memory would be
significant.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.