char [length] initialization and dealing with it

前端 未结 5 1361
长情又很酷
长情又很酷 2021-01-28 08:42

I have defined a char array:

char d[6];

Correct me if I\'m wrong regarding following:

At this moment no memory is allocated for variabl

5条回答
  •  时光说笑
    2021-01-28 09:21

    How to know was char[] initialized? I need pattern if filled(d){..}
    

    Just do this while declaring the character array:

    char d[6];
    d[0] = 0;
    

    Then you can check like this:

    if(strlen(d) == 0)
    //d is not initialized
    

提交回复
热议问题