Assigning a pointer to an integer

前端 未结 5 1983
[愿得一人]
[愿得一人] 2020-12-07 02:48

Can I assign a pointer to an integer variable? Like the following.

int *pointer;
int array1[25];
int addressOfArray;

pointer = &array1[0];

addressOfAr         


        
5条回答
  •  执笔经年
    2020-12-07 03:22

    No, it is no valid to assign a pointer to an integer. It's a constraint violation of the assignment operator (C99, 6.5.16.1p1). A compiler has the right to refuse to translate a program with a pointer to integer assignment.

提交回复
热议问题