2017-03-05 1 views
0

나는이 얻을 :컴파일 오류 : 내 코드를 컴파일 할 때 해당 파일이나 디렉토리

fatal error: includes.h: No such file or directory. 
왜이 오류를 던지고있다

?

이 프로그램은 링크 된 목록을 보여줍니다.

#include "includes.h" 
ListType list[5]; 
int main() 
{ 
ListType list[5]; 
list[0].value = 0; list[0].next = list+1; 
list[1].value = 10; list[1].next = list+2; 
list[2].value = 20; list[2].next = NULL; 
ListReport(list); 
// Insert an element 
list[3].value = 15; list[3].next = list+2; 
list[1].next = list+3; 
ListReport(list); 
// Remove an element 
list[0].next = list+3; 
ListReport(list); 
return 0; 
} 
// Report values in linked lisk 
void ListReport(ListType *plist) 
{ 
int nn = 0; 
printf("ListReport\n"); 
while(plist != NULL){ 
printf("%d, value = %d\n",nn++, plist->value); 
plist = plist->next; 
} 
} 
/******************************************************* 
* includes.h 
******************************************************/ 
#include <stdio.h> 
#include <stdlib.h> 
typedef struct entry 
{ 
int value; 
struct entry *next; 
} ListType; 
void ListReport(ListType *plist); 

// end of includes.h 
+0

주 파일과 동일한 폴더에 includes.h가 있습니까? – vadim

답변

0

코드가 .cpp와 .h 파일을 하나로 연결하는 것 같습니다. 그들을 2 개의 파일로 분리해야합니다. 그래서 같이

:

MAIN.CPP

#include "includes.h" 
ListType list[5]; 
int main() 
{ 
ListType list[5]; 
list[0].value = 0; list[0].next = list+1; 
list[1].value = 10; list[1].next = list+2; 
list[2].value = 20; list[2].next = NULL; 
ListReport(list); 
// Insert an element 
list[3].value = 15; list[3].next = list+2; 
list[1].next = list+3; 
ListReport(list); 
// Remove an element 
list[0].next = list+3; 
ListReport(list); 
return 0; 
} 
// Report values in linked lisk 
void ListReport(ListType *plist) 
{ 
int nn = 0; 
printf("ListReport\n"); 
while(plist != NULL){ 
printf("%d, value = %d\n",nn++, plist->value); 
plist = plist->next; 
} 
} 

INCLUDES.H

#include <stdio.h> 
#include <stdlib.h> 
typedef struct entry 
{ 
    int value; 
    struct entry *next; 
} ListType; 
void ListReport(ListType *plist); 

은 또한 당신은 당신이 가지고있는 것처럼 파일을 결합하고 정상에서 #include 구문을 제거 할 수 있습니다.

+0

감사합니다, u가 맞았습니다 – johnsmith

+0

사용하기 전에 typedef 문을 맨 위에 놓으십시오. –

관련 문제