In the following program I'm trying to set the first, second, & third character values stored in processTheseThree [0], [1], & [2] to the int values D1, D2, & D3. When I tested my code with the linestd::cout << processTheseThree[firstSecondThird] << std::endl;
I was getting the correct values but when I try to assign those values to my D3 int variables I'M getting really hight number like 48-51, even when I only input 123. Also, don't worry about the recourses.h file, it just hold an array of strings that I'm not currently using.
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "resources.h"
int main(int argc, char *argv[])
{
char inputNumber[25] = "000000000000";
strcat(inputNumber, argv[1]);
std::cout << inputNumber << std::endl;
char *input = inputNumber + strlen(inputNumber) - 12;
std::cout << input << std::endl;
int groups = 4;
char processTheseThree[4] = "";
char *theCharIncrementer = input + 9;
int firstSecondThird = 0;
while(groups > 0)
{
strncpy(processTheseThree, theCharIncrementer, 3);
// processTheseThree[theCharIncrementer + 4] = '\0';
//processTheseThree[3] = '\0';
//std::cout << processTheseThree << std::endl;
//while(firstSecondThird < 3)
//{
//std::cout << processTheseThree[firstSecondThird] << std::endl;
int D1 = (int)processTheseThree[0];
int D2 = (int)processTheseThree[1];
int D3 = (int)processTheseThree[2];
std::cout << D1 << std::endl << D2 << std::endl << D3 << std::endl;
//firstSecondThird++;
//}
theCharIncrementer -= 3;
groups--;
}
return 0;
}
/*END*/