Hello guys,
I'm learning about functions and i have some trouble with my code.
I'm trying to write a program that calculates the average of numbers. the first stage is to ask the user how many numbers he wants to calculate, and than scan the numbers to an int type array.
Code:
#include <stdio.h>
#include <stdlib.h>
void ScanInput(int numCount){
int storage[numCount];
for (int i=0; i < numCount; i++) {
scanf ("%d ", &storage);
}
printf("%d\n", &storage[0]);
}
void main(){
int numCount;
printf ("How many numbers do you want to calculate? ");
scanf ("%d ", &numCount);
ScanInput(numCount);
}
In the function i used printf just to see that everything is fine with the scaning, but i'm getting strange output, I build and run the program, scaning the first number lets say its 12, the output is "1176217296"... i can't see the problem, why its not printing 12 instead of the 1176...
Thank you for your time guys!