首页 > 代码库 > [skill] C与C++对于类型转换的验证

[skill] C与C++对于类型转换的验证

不多说了,代码说明一切。

/home/tong/Src/copyleft/test [tong@T7] [11:15]
> gcc 1.c 

/home/tong/Src/copyleft/test [tong@T7] [11:15]
> g++ 1.c 
1.c: In function ‘int main(int, char**)’:
1.c:8:6: error: invalid conversion fromvoid*’ to ‘int*’ [-fpermissive]
  p = q;
      ^

/home/tong/Src/copyleft/test [tong@T7] [11:15]
> cat 1.c 
#include <stdio.h>

int main(int argc, char** argv)
{
        int* p;
        void* q;

        p = q;

        return 0;
}

/home/tong/Src/copyleft/test [tong@T7] [11:15]
> 

 

[skill] C与C++对于类型转换的验证