#include <stdio.h>

int main() {
    // Declarations
    int iCount1, iCount2;
    int iXXTest[4][3] = {{2, 3, 5}, {9, 8, 6}, {1, 8, 4}, {5, 9, 7}};

    // Walk through 1st dimension
    for (iCount1 = 0; iCount1 < 4; iCount1++) {
        // Walk through 2nd dimension
        for (iCount2 = 0; iCount2 < 3; iCount2++) {
            printf("iXXTest[%d][%d] is at address %d and has a value of %d.\n", iCount1, iCount2, &iXXTest[iCount1][iCount2], iXXTest[iCount1][iCount2]);
        }
    }

    return 0;
}

此行生成警告:
printf("iXXTest[%d][%d] is at address %d and has a value of %d.\n", iCount1, iCount2, &iXXTest[iCount1][iCount2], iXXTest[iCount1][iCount2]);

int格式,指针arg(arg 4)
这个警告是关于什么的?我如何解决它?

最佳答案

这意味着您使用了%d(整数)的格式,但参数实际上是一个指针。改用%p。

08-16 20:56