In the function:
Code:
string ZipCode::zipToBar(int zip) { //Converts zip to bar code
int zipArr[5];
string ZERO = "11000",
ONE = "00011",
TWO = "00101",
THREE = "00110",
FOUR = "01001",
FIVE = "01010",
SIX = "01100",
SEVEN = "10001",
EIGHT = "10010",
NINE = "10100";
for (int i = 4; i >= 0; i--) { //Converts integer zip into and array zipArr
zipArr[i] = zip % 10;
zip /= 10;
};
for (int i = 0; i < 5; i++) { //Concatenates strings onto barCode according to the current position in zipArr
if (zipArr[i] == 0)
barCode += ZERO;
else if (zipArr[i] == 1)
barCode += ONE;
else if (zipArr[i] == 2)
barCode += TWO;
else if (zipArr[i] == 3)
barCode += THREE;
else if (zipArr[i] == 4)
barCode += FOUR;
else if (zipArr[i] == 5)
barCode += FIVE;
else if (zipArr[i] == 6)
barCode += SIX;
else if (zipArr[i] == 7)
barCode += SEVEN;
else if (zipArr[i] == 8)
barCode += EIGHT;
else if (zipArr[i] == 9)
barCode += NINE;
};
barCode = "1" + barCode + "1"; //Adds a "1" to each end of barCode
return barCode;
}
I previously had "if (zipArr[i] = 0) ... ... etc" and I'm surprised it never gave me any errors. changing it to the code above fixed the problem.