error

Hi.Here's my code:
1
2
3
4
     char s[7]="76111";
     
     while(*s)
     cout << s-- ;


Why do I get error on the last line?
Please run it on other platforms too.Mine is winxp SP3.
Thanks in advance!
Because you're accessing memory you shouldn't.
But I don't get error in
1
2
char *s="74\01203";
cout << s--;

Why is that?
Just because you do something wrong doesn't mean you get an error. Sometimes you are unlucky and it "works" anyway.
Last edited on
What do you think it will do? You are moving down the string, not up it.
What are you trying to do, maybe we can help you with it
I just want to test where I get syntax error
you haven't told us what the error is yet, hint: it normally shows up at the bottom of the screen after you try and build the project
I guess I found the problem.It wasprobably modifying the constant pointer.I will report any other problem I find later.
Topic archived. No new replies allowed.