Is my compiler not working properly?

Hi,
I've been programming for about three weeks now using Xcode. There's been the occasional compilation oddity but for the majority of the time, everything's been working just fine. These past two days I've been tackling pointers, and discovered a persistent problem. Let me explain:

1
2
3
4
5
6
char *aString = "Hello";
char *p;
p = aString;

std::cout << *p ;//Should print 'H' on the console.
std::cout << *(p+4); //Should print 'o' on the console. 


Now let's say that I change *(p+4) to *(p+1). It should instead print 'e' instead, right? But sometimes it doesn't do that, it acts as though I never changed the value inside the parentheses. And once it acts up like this, it can do this even after trying several times, with or without changing anything.

This makes my progress a little harder and more time consuming, and I can't afford this in the future, because I have two weeks to learn about pointers classes, inheritance, exceptions, templates and a bunch of other things.

So, something wrong with my compiler, or is the problem rooted elsewhere?
It's possible that the program's not being rebuilt after each change. You may want to check the file's timestamp if you're not sure.
No, it changes, so it is being rebuilt. In fact, I've tried to build it before running it every time (so Build and then Run as opposed to Build And Run).

Sometimes it works, sometimes it doesn't. While I've tried restarting Xcode, I've yet to try to restart my computer, so I'll do that now. However, I don't see how it would help...
I have tried compiling this using g++ multiple times with varying values for x in *(p+x);, but it seems to be working fine for me. I have no experience with Xcode, nor do I have a Mac, but I would try re-running the code on your machine using another compiler to see what happens. I'm pretty sure you can use g++ on a mac, but other options must exist too. Once you figure out if the problem is with Xcode then hopefully you can see if it's a settings problem or something with the help of someone who know's Xcode better than myself.
Topic archived. No new replies allowed.