There are a few errors in this code:

  1. The function fun is missing a semicolon at the end of its declaration.
  2. The printf statement in fun is using the incorrect escape character for a new line. It should be \n instead of /n.
  3. In the printf statement in fun, the format specifier %-2d is used, which will print the integer with a minimum width of 2 characters and left-align it. However, since all the integers in the array are single-digit, this format specifier is unnecessary and can be simplified to %d.
  4. In the main function, the return type should be int instead of void.
  5. The main function is missing a return statement at the end.

Here is the corrected code:

#include <stdio.h>

void fun(int array[4][4]) {
    int j;
    for (j = 0; j < 4; j++) {
        printf("%d ", array[2][j]);
    }
    printf("\n");
}

int main(void) {
    int a[4][4] = {{0,1,2,0},{1,0,0,4},{2,0,0,5},{0,4,5,0}};
    fun(a);
    return 0;
}

This code will print out the numbers in the third row of the a array separated by spaces and followed by a new line:

2 0 0 5
``
void funint array44int j; forj=0;j4;j++ printf-2darray2j; printfnvoid mainvoidint a44=0120100420050450; funa;

原文地址: https://www.cveoy.top/t/topic/fcDa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录