warning C4047: 'initializing' : 'char *' differs in levels of indirection from 'const int '

以下来自MSDN

编译器警告(等级 1)C4047

错误消息

“operator”:“identifier1”与“identifier2”的间接寻址级别不同

指针可指向变量(一级间接寻址),指向另一个指向变量的指针(二级间接寻址)等。

示例

下面的示例生成 C4047:

// C4047.c
// compile with: /W1

int main() {
   char **p = 0;   // two levels of indirection
   char *q = 0;   // one level of indirection

   char *p2 = 0;   // one level of indirection
   char *q2 = 0;   // one level of indirection

   p = q;   // C4047
   p2 = q2;
}

下面的示例生成 C4047:

// C4047b.c
// compile with: /W1
#include 

int main() {
   int i;
   FILE *myFile = NULL;
   errno_t  err = 0;
   char file_name[256];
   char *cs = 0;

   err = fopen_s(&myFile, "C4047.txt", "r");
   if ((err != 0) || (myFile)) {
      printf_s("fopen_s failed!/n");
      exit(-1);
    }
   i = fgets(file_name, 256, myFile);   // C4047
   cs = fgets(file_name, 256, myFile);   // OK

}

你可能感兴趣的:(c,File,null,编译器)