Proper way to initialize a string in C

后端 未结 11 1243
臣服心动
臣服心动 2021-02-01 08:23

I\'ve seen people\'s code as:

char *str = NULL;

and I\'ve seen this is as well,

char *str;

I\'m wonder, what

11条回答
  •  一向
    一向 (楼主)
    2021-02-01 09:11

    It depends entirely on how you're going to use it. In the following, it makes more sense not to initialize the variable:

    int count;
    while ((count = function()) > 0)
    {
    }
    

提交回复
热议问题