assignment makes integer from pointer without a cast

后端 未结 2 891
南方客
南方客 2021-01-29 08:34

In the below code am getting an error while am assigning len1 to array a The error is

assignment makes integer from pointer without a         


        
2条回答
  •  抹茶落季
    2021-01-29 09:22

    The problem is that a[4] is a char, whereas len1 is an array of chars!

    When you declare

    char a[7] = {...}
    

    You're saying that you want a to be an array of chars and you're initializing the values at a to the values in {...}.

    When you say a[4] you're saying go 4 along from where a is and use the value there, which is a char. But len1 is a char pointer so when you assign it to a[4] you get the warning!

提交回复
热议问题