Original Post
For the past 2 hours I've been trying to figure out why my program is returning incorrect outputs. I changed all of my integer variables into unsigned integers after realizing some of the numbers I'm working with are out of the integer range. But even after fixing that, 32 numbers out of the 1024 are coming out incorrectly. variables d10Numbers[0] ~ d10Numbers[990] come out fine. 991~1023 come out with values in the upper range of the unsigned int.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void setD10Numbers(unsigned int* const d10Numbers,unsigned int* const d5NUMBERS);
int main()
{
unsigned int d5NUMBERS[32] = {11111,
11112,11121,11211,12111,21111,
11122,11212,12112,21112,11221,12121,21121,12211,21211,22111,
22211,22121,21221,12221,22112,21212,12212,21122,12122,11222,
12222,21222,22122,22212,22221,
22222};
vector< vector<string> > genotype(1024); //declaring genotypes.
for (int i = 0; i < 1024; ++i)
{
genotype.resize(1024);
}
(genotype[1023])[542] = "5421";
cout << (genotype[1023])[542];
unsigned int d10Numbers[1024];
d10Numbers[1023] = 0; // for use in setParent function
setD10Numbers(d10Numbers,d5NUMBERS);
unsigned int x = 0;
while(x < 1024) // testing to see if the function worked
{
cout << d10Numbers[x];
cout << ",";
cout << x;
cout << ",";
x++;
}
return 0;
}
void setD10Numbers(unsigned int* const d10Numbers,unsigned int* const d5NUMBERS)
{
int x,i,c;
x = i = c = 0;
while(d10Numbers[1023] == 0)
{
d10Numbers[c] = (d5NUMBERS[x] * 100000) + d5NUMBERS;
c++;
i++;
if(i==31)
{
x++;
i = 0;
}
}
}