Hello,
I am no C++ genius, but
++*p++
Cannot be a statement by itself, as there is no ; to finish it.
I am trying to remember if *p is significant. I know that &p is... the address of the variable p. p++ is just an incrementor. But C++ has been a "variable first, then operator" type of language. cars++ people--
I think it is an error.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
Increment the object pointed to by p, then increment the pointer p (point to the next object).
#include <stdio.h>
int main(void)
{
char text[] = "1b#", *p = text;
printf("text = \"%s\", p(%p) = \"%s\", *p = '%c'\n", text, (void*)p, p, *p);
++*p++;
printf("text = \"%s\", p(%p) = \"%s\", *p = '%c'\n", text, (void*)p, p, *p);
return 0;
}
/* my output
text = "1b#", p(0012FF88) = "1b#", *p = '1'
text = "2b#", p(0012FF89) = "b#", *p = 'b'
*/
Really, this code is trivial to come up with on your own. At least give these a try.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Hello,
I stand corrected. Reading another post in the forum, people apparently do use ++variable syntax. I always took the style of variable++ and went with it to avoid confusion.
So
++p would be valid.
++*p++ I think is a problem.
Christian
kc0arf
Posting Virtuoso
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57