vendredi 27 février 2015

How to include both for loop initial declarations and gnu extensions?

I have this code:



#include <string.h>
#include <stdio.h>

char numbers[5] = "12345";

int main(){
memrchr(numbers,'2',5);
for(int i=0;i<5;i++){
printf("%d",i);
}
return 0;
}


It uses for loop inital declarations (for(int i) and gnu extensions (memrchr).


I am using the compiler gcc


The problem is that it doesn't seem to let both go through. I can either do



gcc program.c -o program


Which complains about the for loops, or I can do



gcc -std=gnu11 program.c -o program


Which complains about memrchr being undefined. (or rather it complains about the implicit declaration of the function)


How do I do both? Is it possible?


Aucun commentaire:

Enregistrer un commentaire