Mam problemy jak zawsze :D Otóż ten kawałek kodu
int menu(struct Menu **first)//wczytujemy menu główne :)
{
FILE*menu;
menu=fopen("menu.txt", "r");
if(menu==NULL)
{return 1;}
struct Menu *new;
new=(struct Menu*)malloc(sizeof(struct Menu));
struct Menu *prev;
*first=new;
prev=NULL;
while(!feof(menu))
{
fscanf(menu, "%s %i\n", new->function, &new->option);
struct Menu *temp;
temp=(struct Menu*)malloc(sizeof(struct Menu));
temp->next=*first;
new->next=temp;
new->prev=prev;
new=temp;
}
fclose(menu);
return 0;
}
Ma za zadanie wczytać mi na liste zawartość pliku :) robi to świetnie dla list jednokierunkowych cyklicznych. Ja mam mały problem z przerobieniem tego na 2 kierunkowe - miałem problemy z listami a sposób jaki obmysliłem jest dość nieporfesjonalny a wiem, że jest łatwiejszy. Czyli funkcja ma ogólnie tworzyć listę 2 kierunkową cykliczną.
Druga część tematu dotyczy tego kawałka kodu
char *distribution;
char *temp;
char *temp2;
char program[100];
char which[100]="which ";
char dis[100];
int back;
temp=distribution;
temp2=which;
while(!feof(list))
{
fscanf(list, "%s", program);
strcat(distribution, program); <- tutaj warning mi wywala
strcat(which, program);
back=system(which);
if(back==0){back=1;}
if(back!=0)
{
back=system(dis);
}
distribution=temp;
which=temp2; <- tutaj błędzik :)
add_to_list(back,program);
}
To mi wywala gdy kompiluje
install.c: In function ‘install’:
install.c:86: warning: incompatible implicit declaration of built-in function ‘strcat’
install.c:95: error: incompatible types when assigning to type ‘char[100]’ from type ‘char *’
Jak temu zaradzić?