0

The code below generates the following error:

  • format specifies type 'int' but the argument has type 'int *' [-Werror,-Wformat]
    printf("%i", array);

include

include

int main(void) {
    int array[6];
    for (int i = 0; i < 6; i++) {
        array[i] = get_int();
     }
printf("%i", array);

}

0

If you want to print each value in the array, you need to use a loop, just as you did for populating the array.

for (int i = 0; i < 6; i++)
{
    printf("%i", array[i]);
}
| improve this answer | |
  • Ahah, thanks so much. If you don't mind me asking... why can't one simply just print all elements in one shot with printf? – Drusk Jul 11 '17 at 3:26
  • simply because the language doesn't have that feature. – curiouskiwi Jul 11 '17 at 3:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .