Pregunta

SO in linux i could probably end a while-loop with this kind of code if I compile with gcc:

#include <stdio.h>

int main()
{   
    int s;
    while(scanf("d%",&s)!=EOF);
    {   
        scanf("%d",&s);
          }
    return 0;
}

However this does not work with a windows computer and the compiler Im using is Microsoft Visual Studio 12. Any suggestions?

¿Fue útil?

Solución

#include <stdio.h>

int main() {
    int s;
    while((s = getchar()) != EOF) {
        printf("%d\n", s);
    }
    printf("%d - at EOF\n", s);
}

you can try this

Otros consejos

Try it with strg + c or strg + z. I think that was which overgives the EOF

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top