[완료]이 소스가 종료가 안돼요 ㅠㅠ
#include
#include
#include
#include
#ifndef MAX_CANON
#define MAX_CANON 8192
#endif
int runproc(char *cmd);
void showhistory(FILE *f);
int main(int argc, char *argv[]) {
char cmd[MAX_CANON];
int history = 1;
if (argc == 1)
history = 0;
else if ((argc > 2) || strcmp(argv[1], "history")) {
fprintf(stderr, "Usage: %s [history]\n", argv[0]);
return 1;
}
while(fgets(cmd, MAX_CANON, stdin) != NULL) {
if (*(cmd + strlen(cmd) - 1) == '\n')
*(cmd + strlen(cmd) - 1) = 0;
if (history && !strcmp(cmd, "history"))
showhistory(stdout);
else if (runproc(cmd)) {
perror("Failed to execute command");
break;
}
}
printf("\n\n>>>>>>The list of commands executed is:\n");
showhistory(stdout);
return 0;
}
//전 여기서 NULL이 while문 빠져 나올때 쓰는 값이라
그냥 enter 치면 나오는 지알고 했는데 안돼서
한칸 뛰우고도 하고 다 해봤지만
결국엔ctrl+c 강종했습니다 ㅠㅠ
왜 안돼는거죠?;;;
페도라 13을 쓰는거 하곤 관계가 없을텐데 제가 뭐를 잘못 알고 있는걸까요? ㅠㅠ
너무 초짜라 수업 내용도 벅차네요;;;
좀 알려 주세요 ㅠㅠ
첨부 | 파일 크기 |
---|---|
![]() | 10 KB |
![]() | 220 KB |
엔터를 치면
엔터를 치면 엔터(뉴라인또는 캐리지리턴 문자)를 입력 받았으므로 NULL이 되지 않습니다.
아 그렇군요
그럼 어떻게 해야 정상 종료가 되면서
history에 저장된것이 출력이 되는겁니까?;
아 ㅠㅠ 컨트로 +@ 도 안되네요
ㅠㅠㅠㅠㅠ
드디어 했습니다 ㅠㅠ 위에 도움말 주신분 감사합니다.
뭐 찾다가 찾다가 계속 찾다 보니까 나오네요 ㅠㅠ
댓글 달기