Эта ошибка продолжает появляться, и я не знаю, как ее решить.
Пожалуйста, помогите! ошибка всплывает в этой строке:
---fscanf(ifp, "%s", archive.team[i].color);---
ожидается const char *, но аргумент имеет тип char
Существует также "passing argument 2 of strcmp makes pointer from integer without a cast"
ошибка в строке:
---if (strcmp(archive.team[j].name, name) == 0){---
Вот сокращенный вариант моего кода --------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------------
#include <stdio.h>
struct dragon {
char name[40] ;
char color[40] ;
};
struct collection {
struct dragon team[1000];
int num_dragons;
};
int main() {
struct collection archive;
FILE * ifp = fopen("dragon.txt", "r");
int i, j, k, l, m, updates, n=0;
char directions, color, name, ADD, REMOVE, SEARCH, LIST, rem;
fscanf(ifp, "%d", &updates);
for (i=0; i<updates; i++){
fscanf(ifp, "%s", directions);
if (directions==ADD){
fscanf(ifp, "%s", archive.team[i].name);
fscanf(ifp, "%s", archive.team[i].color);
printf("%s the %s has been added to the team.", archive.team[i].name, archive.team[i].color);
}
else if (directions==REMOVE){
fscanf(ifp, "%s", name);
for (j=0; j<updates; j++){
if (strcmp(archive.team[j].name, name) == 0){
strcpy(archive.team[j].name, "rem");
strcpy(archive.team[j].color, "rem");
printf("%s the %s has been removed from the team.", name, archive.team[j].color);
}
}
}
else if (directions==SEARCH){
fscanf(ifp, "%s", name);
for (k=0; k<updates; k++){
if (strcmp(archive.team[k].name, name) == 0)
printf("%s the dragon is currently on the team.", name);
}
for (l=0; l<updates; l++){
if (strcmp(archive.team[l].name, name) == 0)
n++;
}
if (n==0)
printf("%s the dragon is NOT currently on the team.", name);
}
else if (directions==LIST){
fscanf(ifp, "%s", color);
printf("%s dragons:\n", color);
for (m=0; m<updates; m++){
if (strcmp(archive.team[m].color, color) == 0)
printf("%s\n", archive.team[m].name);
}
}
}
декларацию 'archive'? –
Пожалуйста, напишите полный проверяемый код http://stackoverflow.com/help/mcve –
«Конденсированная версия» вашего кода не годится, если вы не разделяете важные части и оставляете глупости, как «введите код здесь». –