简体   繁体   中英

Can't initialize variables in for loop in C in VSCODE

I think something wrong with my VSCode, since i can't initialize varibles in loops in C For instance:

    #include <stdio.h>

    int main(){
     for(int i = 0; i < 5; i++){
      printf("%i", i);
     }
     }

It gives compile error How can I fix it? Thanks in advance

either declare i prior to the for loop or compile with "-std=c99"

#include <stdio.h>

int main(){
    int i = 0;
    for(i = 0; i < 5; i++){
    printf("%i", i);
    }
 }

 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM