下記のプログラムを作ったのですが
C
1コード 2#include <stdio.h> 3#include <stdlib.h> 4#include <string.h> 5#define SIZE 10 6typedef struct element { 7 char name[SIZE]; 8 struct element *next; 9} element_type; 10 11void inputList(element_type **head); 12int find(element_type **head, char target); 13 14void inputList(element_type **head) { 15 int num; 16 printf("Elenemt num:"); 17 scanf("%d", &num); 18 19 element_type** tail = head; 20 int i; 21 for (i = 1; i <= num; ++i) { 22 char name[SIZE]; 23 printf("Element %d:", i); 24 scanf("%s", &name); 25 *tail = malloc(sizeof(element_type)); (*tail)->name = name; 26 (*tail)->next = NULL; 27 tail = &((*tail)->next); 28 } 29} 30 31int find(element_type **head, char target) { 32 element_type **p; 33 element_type *tmp; 34 int index = 0; 35 p = head; 36 while (*p != NULL) { 37 if((*p)->name == target){ 38 return index; 39 } else{ 40 } 41 index++; 42 } 43} 44int main(void) { 45 element_type *list = NULL; 46 element_type *p; 47 int index; 48 char target[SIZE]; 49 50 inputList(list); 51 52 printf("Input target:"); 53 scanf("%s", &target); 54 index = find(&list, target); 55 56 printf("#%d\n", index); 57 while(list != NULL) { 58 p = list; 59 printf("%s ", p->name); 60 list = p->next; 61 free(p); 62 } 63 printf("\n"); 64 return 0; 65}
で以下のエラーメッセージが表示されすのですがどこを変えれば良いでしょうか
コード test3-1-1.c:23:17: warning: format specifies type 'char *' but the argument has type 'char (*)[10]' [-Wformat] scanf("%s", &name); ~~ ^~~~~ test3-1-1.c:24:57: error: array type 'char [10]' is not assignable *tail = malloc(sizeof(element_type)); (*tail)->name = name; ~~~~~~~~~~~~~ ^ test3-1-1.c:36:19: warning: comparison between pointer and integer ('char *' and 'char') [-Wpointer-integer-compare] if((*p)->name == target){ ~~~~~~~~~~ ^ ~~~~~~ test3-1-1.c:49:13: warning: incompatible pointer types passing 'element_type *' (aka 'struct element *') to parameter of type 'element_type **' (aka 'struct element **'); take the address with & [-Wincompatible-pointer-types] inputList(list); ^~~~ & test3-1-1.c:13:31: note: passing argument to parameter 'head' here void inputList(element_type **head) { ^ test3-1-1.c:52:15: warning: format specifies type 'char *' but the argument has type 'char (*)[10]' [-Wformat] scanf("%s", &target); ~~ ^~~~~~~ test3-1-1.c:53:23: warning: incompatible pointer to integer conversion passing 'char [10]' to parameter of type 'char' [-Wint-conversion] index = find(&list, target); ^~~~~~ test3-1-1.c:30:36: note: passing argument to parameter 'target' here int find(element_type **head, char target) { ^