error C2143: syntax error : missing ';' before 'type'

前端 未结 3 904
有刺的猬
有刺的猬 2020-12-01 17:55

I am new to programming C.. please tell me what is wrong with this program, and why I am getting this error: error C2143: syntax error : missing \';\' before \'type\

3条回答
  •  感情败类
    2020-12-01 18:37

    this:

    int i=1;
    for(;i<=5; i++) {
    

    should be idiomatically written as:

    for(int i=1; i<=5; i++) {
    

    because there no point to declare for loop variable in the function scope.

提交回复
热议问题