2011-04-07 4 views
1

내가 Dev-C++를 사용하면서 컴파일 할 때 3 개의 오류가 발생합니다.포인터, 파일 및 함수에 대한 도움이 C

#include <stdio.h> 
#include <conio.h> 
#include <stdlib.h> 
#include <string.h> 

struct agenda{ 
    char nombre [50]; 
    char telefono[25]; 
    char email[50]; 
    } 
    struct nodo{ 
     struct agenda dato; 
     struct nodo *proximo;  
     } 

    struct nodo *nuevonodo 
      int colavacia(struct nodo *) 
    struct nodo *creacola (struct nodo *, struct agenda); 

    void mostrar (struct nodo *); 

    void main() 
    { 
     struct nodo *pri=NULL, *ult=NULL; 
     struct agenda x; 

     printf ("ingrese nombre: "); 
     gets(x.nombre); 
     while (strcmpi(x.nombre, "fin")) 

    { 
     printf ("ingrese telefono: "); 
     gets (x.telefono); 
     printf ("ingrese mail: "); 
     gets(x.mail); 
     ult=creacola(ult,x); 
     if (pri==NULL) pri=ult; //si es la 1 pasada pongo en pri el valor del primer nodo 
     printf ("ingrese nombre: "); 
     gets(x.nombre); 
    } 
    if (colavacia(pri)==1) 
    { 
    printf ("No se ingresaron registros");getch(); 
    } 
    else mostrar(pri); 

    } 
    struct nodo *nuevonodo() 
    { 
     struct nodo *p; 
     p=(struct nodo *)malloc(sizeof(struc nodo)); 
     if(p==NULL) 
     { 
      printf ("memoria ram llena"); 
      getch(); 
      exit(0); 
     } 
     return p; 
    } 

    struct nodo *creacola(struct nodo *ult, struct agenda x) 
    { 
     struct nodo *p; 
     p=nuevonodo(); 
     (*P).dato=x; 
     (*p).proximo=NULL; 
     if(ult!=NULL) (*ult).proximo=p; //si hay nodo anterior en prox pongo la direccion del nodo actual 
     return p; 
    } 

    int colavacia(struct nodo *pri) 
    { 
     if(pri==NULL) return 1; 
     else 
     return 0; 
    } 

    void mostrar (struct nodo *pri) 
    { 
     struct nodo *aux; 

    while(pri!=NULL) 
    { 
     printf("Nombre: %s - telefono: %s - Mail: %s \n", 
     pri->dato.nombre,pri->dato.telefono,pri->dato.mail); 
     aux=pri; 
     pri=(*pri).proximo; 
     free(aux); 
    } 
    getch(); 
} 
+6

컴파일러에서받은 컴파일 오류를 추가해야합니다 ... – mmccomb

+0

"int"앞에 구문 오류가 있으며 전원이 실패 함을 나타냅니다. int colavacia (struct nodo *) – user697553

+1

** 적 ** 항상 ** 'gets()'를 사용하십시오. **못!**. 결코 "결코"말하지 마라. 사람들에게'gets()'에 대해서 말할 때를 제외하고. 'gets() '를 사용하면 방어 적으로 코드를 작성하고 버퍼 오버 플로우를 피할 수 없습니다. ** 대신'fgets()'를 사용하십시오. **'fgets (x.telefono, sizeof x.telefono, stdin);' – pmg

답변

3

세미콜론으로 struct 정의를 종료해야합니다

변수 및 함수 선언에 대한 유사
struct agenda{ 
    char nombre [50]; 
    char telefono[25]; 
    char email[50]; 
}; // <- HERE 

:

struct nodo *nuevonodo; 
int colavacia(struct nodo *); 

그리고 main의 반환 값이 int을 입력합니다.

3
5587527.c:2:19: fatal error: conio.h: No such file or directory

난 불쾌감 #include을 주석 다시

 
5587527.c:11:5: error: two or more data types in declaration specifiers 
5587527.c:16:5: error: two or more data types in declaration specifiers 
5587527.c:17:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’ 
cc1: warnings being treated as errors 
5587527.c:22:10: error: function declaration isn’t a prototype 
5587527.c:22:10: error: return type of ‘main’ is not ‘int’ 
5587527.c: In function ‘main’: 
5587527.c:22:10: error: old-style function definition 
5587527.c:29:9: error: implicit declaration of function ‘strcmpi’ 
5587527.c:29:9: error: nested extern declaration of ‘strcmpi’ 
5587527.c:35:15: error: ‘struct agenda’ has no member named ‘mail’ 
5587527.c:36:9: error: implicit declaration of function ‘creacola’ 
5587527.c:36:9: error: nested extern declaration of ‘creacola’ 
5587527.c:36:12: error: assignment makes pointer from integer without a cast 
5587527.c:41:5: error: implicit declaration of function ‘colavacia’ 
5587527.c:41:5: error: nested extern declaration of ‘colavacia’ 
5587527.c:43:5: error: implicit declaration of function ‘getch’ 
5587527.c:43:5: error: nested extern declaration of ‘getch’ 
5587527.c: At top level: 
5587527.c:48:18: error: function declaration isn’t a prototype 
5587527.c: In function ‘nuevonodo’: 
5587527.c:48:18: error: old-style function definition 
5587527.c:51:40: error: ‘struc’ undeclared (first use in this function) 
5587527.c:51:40: note: each undeclared identifier is reported only once for each function it appears in 
5587527.c:51:46: error: expected ‘)’ before ‘nodo’ 
5587527.c: At top level: 
5587527.c:61:18: error: conflicting types for ‘creacola’ 
5587527.c:36:13: note: previous implicit declaration of ‘creacola’ was here 
5587527.c: In function ‘creacola’: 
5587527.c:65:11: error: ‘P’ undeclared (first use in this function) 
5587527.c: In function ‘mostrar’: 
5587527.c:85:54: error: ‘struct agenda’ has no member named ‘mail’ 

I는 ; 라인 10, 14, 16, 17에 가하고

 
cc1: warnings being treated as errors 
5587527.c:22:10: error: function declaration isn’t a prototype 
5587527.c:22:10: error: return type of ‘main’ is not ‘int’ 
5587527.c: In function ‘main’: 
5587527.c:22:10: error: old-style function definition 
5587527.c:29:9: error: implicit declaration of function ‘strcmpi’ 
5587527.c:29:9: error: nested extern declaration of ‘strcmpi’ 
5587527.c:35:15: error: ‘struct agenda’ has no member named ‘mail’ 
5587527.c:43:5: error: implicit declaration of function ‘getch’ 
5587527.c:43:5: error: nested extern declaration of ‘getch’ 
5587527.c: At top level: 
5587527.c:48:18: error: function declaration isn’t a prototype 
5587527.c:48:18: error: ‘nuevonodo’ redeclared as different kind of symbol 
5587527.c:16:18: note: previous declaration of ‘nuevonodo’ was here 
5587527.c: In function ‘nuevonodo’: 
5587527.c:48:18: error: old-style function definition 
5587527.c:51:40: error: ‘struc’ undeclared (first use in this function) 
5587527.c:51:40: note: each undeclared identifier is reported only once for each function it appears in 
5587527.c:51:46: error: expected ‘)’ before ‘nodo’ 
5587527.c: In function ‘creacola’: 
5587527.c:65:11: error: ‘P’ undeclared (first use in this function) 
5587527.c: In function ‘mostrar’: 
5587527.c:85:54: error: ‘struct agenda’ has no member named ‘mail’ 
다시 시도했다 시도한

수정(줄)

 
5587527.c: In function ‘main’: 
5587527.c:29:9: error: implicit declaration of function ‘strcmpi’ 
5587527.c:29:9: error: nested extern declaration of ‘strcmpi’ 
5587527.c:35:15: error: ‘struct agenda’ has no member named ‘mail’ 
5587527.c:43:5: error: implicit declaration of function ‘getch’ 
5587527.c:43:5: error: nested extern declaration of ‘getch’ 
5587527.c: At top level: 
5587527.c:48:18: error: function declaration isn’t a prototype 
5587527.c:48:18: error: ‘nuevonodo’ redeclared as different kind of symbol 
5587527.c:16:18: note: previous declaration of ‘nuevonodo’ was here 
5587527.c: In function ‘nuevonodo’: 
5587527.c:48:18: error: old-style function definition 
5587527.c:51:40: error: ‘struc’ undeclared (first use in this function) 
5587527.c:51:40: note: each undeclared identifier is reported only once for each function it appears in 
5587527.c:51:46: error: expected ‘)’ before ‘nodo’ 
5587527.c: In function ‘creacola’: 
5587527.c:65:11: error: ‘P’ undeclared (first use in this function) 
5587527.c: In function ‘mostrar’: 
5587527.c:85:54: error: ‘struct agenda’ has no member named ‘mail’ 

strcmp

 
5587527.c: In function ‘main’: 
5587527.c:35:15: error: ‘struct agenda’ has no member named ‘mail’ 
cc1: warnings being treated as errors 
5587527.c:43:5: error: implicit declaration of function ‘getch’ 
5587527.c:43:5: error: nested extern declaration of ‘getch’ 
5587527.c: At top level: 
5587527.c:48:18: error: function declaration isn’t a prototype 
5587527.c:48:18: error: ‘nuevonodo’ redeclared as different kind of symbol 
5587527.c:16:18: note: previous declaration of ‘nuevonodo’ was here 
5587527.c: In function ‘nuevonodo’: 
5587527.c:48:18: error: old-style function definition 
5587527.c:51:40: error: ‘struc’ undeclared (first use in this function) 
5587527.c:51:40: note: each undeclared identifier is reported only once for each function it appears in 
5587527.c:51:46: error: expected ‘)’ before ‘nodo’ 
5587527.c: In function ‘creacola’: 
5587527.c:65:11: error: ‘P’ undeclared (first use in this function) 
5587527.c: In function ‘mostrar’: 
5587527.c:85:54: error: ‘struct agenda’ has no member named ‘mail’ 

... 내가 당신을 위해 몇 가지 오류를 수정/컴파일/수 이상의 오류를했던 에 29 행에 strcmpi 변경. 이제 네 차례 야.

관련 문제