Question

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?

Was it helpful?

Solution

#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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top