Re: const char pointers
On Nov 2, 8:20 pm, Paul N <gw7...@aol.com> wrote:
On 2 Nov, 16:01, crystal twix <jonwongfanc...@gmail.com> wrote:
[...]
And I forgot to mention that we are not allowed to create
any new variables besides one pointer of type char *.
If this is truly what you are meant to be doing, it's going to
be tricky. One way would to use a pointer (let's call it p) to
point to the place in "result" that you are writing to; you
could then use word [ (p - result) + start ] to be the place
you read from. But this seems much more advanced than the
level you are at at present.
This was my initial impression, but in fact, he's passed a
pointer to the place where he should put the results, so it's
actually possible to solve the problem without any new
variables. (I'd probably use two new pointers, since it's
more or less idiomatic in C++ to use the STL iterator pattern.)
I suspect, however, that the solution the prof is looking for
treats the word and result as arrays, and indexes into them,
despite the fact that they really are pointers, and that such
use is not very idomatic in C++. (Given the assignment, I
suspect that the prof isn't very versed in C++ to begin with.)
--
James Kanze