I'm trying to implement a function that will parse numbers for a calculator assignment that I have been given. A for loop has been set up that will iterate through each index in the input array which is a arithmetic equation e.g "1+2+3+4+5". I created a function isDigit() that will return true or false if the character is between 0 and 9. This is how I am parsing the numbers. My problem is that the numbers are not being permanently stored in my numbers[] array which I would like to return.
Currently the numbers are being printed to the console with the first cout as "12345" but with the second cout (currently commented) which to check what my returned array stores is an ambiguous hex number. Can someone please help me to return "12345" in numbers[].
int * parseNumbers(char input[])
{
static int numbers[10];
for (int i = 0; i < strlen(input); i++)
{
if (isDigit(input[i]))
{
numbers[i] = input[i] - '0';
cout << numbers[i];
}
}
//cout << numbers << endl;
return(numbers);
}
numbers = 1, 2, 3, 4, 5
currently getting numbers = 002D26E8