I started to get really good at programming but then I reached a part in this course that I always hate: Arrays. I never completely understood arrays in C++ and it's very confusing to me. I have a very simple program and I just need a little bit of help on what I'm doing wrong.
Here is my code so far:
#include <stdio.h>
#include <stdlib.h>
main() {
int num[50];
int i;
for (i = 0; i < 50; i++) {
printf("Enter a number (-999 to quit)\n ");
scanf("%i", &num[i]);
if (num == -999) {
printf("you chose to quit\n ");
}
}
printf("The numbers you entered are %i \n", num);
system("pause");
}
My questions are:
Why isn't -999 working properly? In a previous program I just used while (num != -999)
and it worked great but it doesn't seem to be working in this case either.
Why isn't the array printed out properly?
Please let me know what I'm doing wrong.