Hello. Just dusting off my function knowladge in relation to pointers for refactoring in a larger project. Came up on this discrepancy. See my verbose debug output. Problem around for loop in function. Short post because adblock wiped my post form two times. :)
#include <stdio.h>
int mult(int x, int y, int *str[]);
int str[5];
int main()
{
int x,y,i;
for (i = 0; i < 5; i++) str[i] = i;
printf("Please input two numbers to be multiplied: ");
scanf_s("%d", &x);
scanf_s("%d", &y);
getchar();
printf("\nThe product of your two numbers is %d\n", mult(x, y, str));
getchar();
}
int mult(int x, int y, int *str[])
{
int o,i;
for (i = 0; i < 5; i++) {
printf("\n str[i] before adding x: %d x value: %d", str[i],x);
str[i] = str[i] + x;
printf("\n str[i] after adding x: %d", str[i]); }
o = x * y;
return o;
}