Reputation: 21
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
Upvotes: 0
Views: 351
Reputation: 74
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);
}
}
Upvotes: 1