Comment envoyer EOF via le terminal Windows

J’essaie de comprendre l’exemple 1.9 du livre K & R, mais je ne comprends pas comment envoyer EOF. Certaines sources mentionnent Ctr + Z, mais cela termine simplement le programme. J’ai en quelque sorte réussi à envoyer EOF avec une combinaison de Enter et Ctrl + Z et peut-être Ctrl + V, mais je ne peux pas le reproduire.

#include  #define MAXLINE 1000 main() { int len; int max; char line[MAXLINE]; char save[MAXLINE]; max = 0; while((len = getline_my(line, MAXLINE)) > 0) if(len > max) { max = len; copy(line, save); } if(max > 0) printf("%S", save); } getline_my(s, lim) char s[]; int lim; { int c, i; for(i=0; i < lim-1 && (c = getchar()) != EOF && c != '\n'; i++)// As long as the condition is fulfilled s[i] = c; if (c == '\n') { s[i] = c; i++; } s[i] = '\0'; return(i); } copy(s1, s2) char s1[]; char s2[]; { int i; i = 0; while((s2[i] = s1[i]) != '\0') i++; } 

Vous pouvez simuler EOF avec CTRL+D (pour * nix) ou CTRL+Z (pour Windows) à partir de la ligne de commande.

Dans les veuves, lorsque vous êtes prêt à compléter l’entrée, appuyez sur la touche Enter , puis appuyez sur Ctrl+Z puis sur Enter pour terminer l’entrée.

 int main(){ char ch[100]; scanf("%[^EOF]",ch); printf("\nthe ssortingng is:\n%s\n",ch); fflush(stdin); return 0; } 

printf("%S", save); -> printf("%s", save);