K & R 책에서 예 1.9를 이해하려고하는데 EOF를 보내는 방법을 모르겠다. 일부 출처는 Ctr + Z에 대해 언급했지만 간단히 프로그램을 종료합니다. 어떻게 든 Enter와 Ctrl + Z, Ctrl + V 조합으로 EOF를 보낼 수 있었지만 재현 할 수는 없습니다.Windows 터미널을 통해 EOF를 보내는 방법
#include <stdio.h>
#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++;
}
CTRL D? 수도 작동하지 않을 수도 –
불행히도 유닉스 용이었던 –
아니에요 .. 이들은 cmd http://ss64.com/nt/syntax-keyboard.html에있는 모든 명령입니다 –