0

Got strucked at array intialization!

I had done a simple code to get value from array but i struck at scanf line please leave your solution https://code.sololearn.com/cJYlBRkNPph3/?ref=app

19th Jul 2020, 3:37 PM
Akash Poovan
Akash Poovan - avatar
2 Answers
0
You just missed a & in your scanf. The following works: #include<stdio.h> int main() { int array[10]; int i; for(i=0;i<10;i++){ scanf("%d",&array[i]);// ampersand required to get memory address to store into. } for(i=0;i<10;i++){ printf("%d",array[i]);// no ampersand needed because the value to print is sufficient. We don't need to know where the value came from. } }
19th Jul 2020, 3:39 PM
Josh Greig
Josh Greig - avatar
0
Thank you so much
19th Jul 2020, 3:43 PM
Akash Poovan
Akash Poovan - avatar