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);

}

1 Answer 1

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]);
}
2
  • 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, 2017 at 3:26
  • simply because the language doesn't have that feature.
    – curiouskiwi
    Jul 11, 2017 at 3:58

You must log in to answer this question.

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