error
| hooshdar3 (143) |
|
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!
|
|
|
| cire (1852) |
|
|
Because you're accessing memory you shouldn't.
|
|
|
| hooshdar3 (143) |
|
But I don't get error in
1 2
|
char *s="74\01203";
cout << s--;
|
Why is that?
|
|
|
| Peter87 (3691) |
|
|
Just because you do something wrong doesn't mean you get an error. Sometimes you are unlucky and it "works" anyway.
|
|
Last edited on
|
| NanoBytes (70) |
|
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
|
|
|
| hooshdar3 (143) |
|
|
I just want to test where I get syntax error
|
|
|
| Zephilinox (548) |
|
|
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
|
|
|
| hooshdar3 (143) |
|
|
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.