I was hoping someone may comment on a behavior I haven't seen before. I've done a work around but this seems so unusual to me I would really like to know why it is happening if possible.
In the code below I call another function twice within the same function. I've changed the code a bit to make it easier to see while still retaining the behavior from the original. As the code is here you can not get the value printed on the line :
printw("%c ", nd_base_num[0]);
although the values at [1], [2], etc will print out.
Code:
void multiply_numbers(char *base_num, char *series_start_num)
{
char nd_base_num[MAXLENGTH - 1], nd_series_start_num[MAXLENGTH - 1];
int base_asint, series_asint;
move(15,0);
remove_decimal(base_num, nd_base_num);
remove_decimal(series_start_num, nd_series_start_num);
printw("%c ", nd_base_num[0]);
printw("%c ", nd_base_num[1]);
printw("%c ", nd_base_num[2]);
printw("%c ", nd_base_num[3]);
The funny thing is that if I move the print command to sit between the the first function and the second call to that function then the value of [0] will print. This code works;
Code:
void multiply_numbers(char *base_num, char *series_start_num)
{
char nd_base_num[MAXLENGTH - 1], nd_series_start_num[MAXLENGTH - 1];
int base_asint, series_asint;
move(15,0);
remove_decimal(base_num, nd_base_num);
printw("%c ", nd_base_num[0]);
printw("%c ", nd_base_num[1]);
printw("%c ", nd_base_num[2]);
printw("%c ", nd_base_num[3]);
remove_decimal(series_start_num, nd_series_start_num);
}
Even more strange is that if I exchange the arguments of the first call with the second and try printing the values of the new arguments to the first call then I can get it print the value at the address [0]. This code works:
Code:
void multiply_numbers(char *base_num, char *series_start_num)
{
char nd_base_num[MAXLENGTH - 1], nd_series_start_num[MAXLENGTH - 1];
int base_asint, series_asint;
move(15,0);
remove_decimal(series_start_num, nd_series_start_num);
remove_decimal(base_num, nd_base_num);
printw("%c ", series_start_num[0]);
printw("%c ", series_start_num[1]);
printw("%c ", series_start_num[2]);
printw("%c ", series_start_num[3]);
}
The arguments the initial function takes ranges between 0 and 9, I've tried the different values and the code still behaves the way it does. Any feedback is appreciated