int *process;
ifstream in(filename);
...
...
...//start going through text file, getting values for n and m
process=new int[n,(m+1),40];
for(i=0;i<n;i++)
{//loop for processes
in.ignore(100,' ');
in>>d;
in.ignore(100,'\n');
in.ignore(100,' ');
in>>c;
process[i,0,0]=d;//inputs value 5 in
process[i,1,0]=c;//inputs value 3 in
cout<<process[i,0,0]<<" "<<process[i,1,0]<<endl;//couts 3 and 3
}//end for
This part of the code is a shortened version of an function that goes through an input file and puts numbers into this 3D array.
I have to use pointers to create the process array after the fact because I don't know what n and m are until I actually get into the file (the first two numbers in the file give me those values).
Now, I test the entire code with a test input. And in said input, it works out so that d and c equal 5 and 3 respectively. When I actually debug the code (using Visual Studio 2008), it shows that d and c equal 5 and 3. When I cout d and c, it shows 5 and 3. But for some reason when I cout process[i,0,0] and process[i,1,0] it gives me 3 and 3.
I have a feeling it has something to do with the pointer only pointing to one value..? But I don't know what to do to fix it.
Any help is appreciated. If you want to see the whole program, I'll give it to you.

New Topic/Question
Reply




MultiQuote





|