Jun 18, 2012 at 4:29pm UTC
Hello I am a beginner in c++, can anyone explain to me when I run my code, oldx[0]=200??? here is my code below.. Thanks in advance!
#include "stdafx.h"
#include "math.h"
#include "iostream"
double oldx[3], oldy[3];
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{oldx[0]=100,oldx[1]=200,oldx[2]=200,oldx[3]=100;
oldy[0]=100,oldy[1]=100,oldy[2]=200,oldy[3]=200;
for (int i=0;i<4;i++)
{cout<<"oldx["<<i<<"] = "<<oldx[i]<<endl;
}
return 0;
}
Last edited on Jun 18, 2012 at 4:30pm UTC
Jun 18, 2012 at 4:34pm UTC
you mean it doesn't come out as oldx[0]=200 for you when you run it???
omg... Ive tried creating new projects and its all the same...
Jun 18, 2012 at 4:44pm UTC
Thanks for the help! If I may ask, what compiler are you using?? I'm using Microsoft Visual Studio 2010
Jun 18, 2012 at 4:56pm UTC
It's at the top of that page: language: C++ (gcc-4.3.4)
Last edited on Jun 18, 2012 at 4:56pm UTC
Jun 18, 2012 at 8:09pm UTC
If I had to guess, oldy[3] has the same address as oldx[0]. You can test it yourself by fetching the addresses of these locations.