How to name variables

前端 未结 24 1330
抹茶落季
抹茶落季 2020-12-01 00:37
  • What rules do you use to name your variables?
  • Where are single letter vars allowed?
  • How much info do you put in the name?
  • How about for exam
24条回答
  •  旧时难觅i
    2020-12-01 01:21

    I never use meaningless variable names like foo or bar, unless, of course, the code is truly throw-away.

    For loop variables, I double up the letter so that it's easier to search for the variable within the file. For example,

    for (int ii=0; ii < array.length; ii++)
    {
        int element = array[ii];
        printf("%d", element);
    }
    

提交回复
热议问题