1

次のエラーが表示されます。

A1.c:1:2: エラー: 無効な前処理ディレクティブ #inlcude
A1.c:29: エラー: 宣言指定子に 2 つ以上のデータ型があります
A1.c: 関数 'main' 内:
A1.c:30: エラー: 互換性がありません代入の型
A1.c: 関数 'insert' 内:
A1.c:45: 警告: 組み込み関数 'printf' の
暗黙的な宣言に互換性がありません A1.c:54: 警告: 組み込み関数 'printf' の暗黙的な宣言に互換性がありません'

次のコードの場合: (このための多くの変数は現時点では不完全であり、多くの作業が必要なため使用されていないことに注意してください。ただし、コードが機能するかどうかをテストするためにコンパイルすることはできません。明らかにそうではありません )

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

#define MAXL 100           //max Last name field length
#define MAXR 100           //max Rest field length
#define MAXM 5             //max message-string length e.g., "FIND"
#define MAXI 520           //max input line length

typedef char Last_t[MAXL];
typedef char Rest_t[MAXR];

void insert(char last[],char rest[]);

//DEFFINITION OF OUR NODE or CONTACT
typedef struct NodeTag {
   Last_t     Last;
   Rest_t     Rest;
   struct NodeTag *Link;
} Node;

//DEFINITION OF CONTACT LIST
typedef struct {
   Node *Index[26];
   Node *L;
} ContactList;

//STATIC CONTACT LIST INITIATED
static ContactList con ;

int void main () {
con.Index= NULL;
con.L = NULL;
insert( "Amir", "S");


}

//create a node and insert it to the List con of ContactList
void insert ( char last[], char rest[]) {
 Node *node, *next, *prev;
 node= malloc (sizeof(Node));
 strcpy(node->Last,last);
 strcpy(node->Rest,rest);
 if (con.L == NULL ){
   node->Link=con.L;
   con.L = node ;
  printf("Added %s %s\n",last,rest);
  }

 else {
  Node *current = con.L ;

  while(current->Link !=NULL) {
     if (current->Link == NULL) {
           current->Link = node;
           printf("Added %s %s\n",last,rest);

     }
     current = current->Link;
  }
 }

}
4

1 に答える 1