Einzelnen Beitrag anzeigen
Alt 13.06.2002, 19:28   #10
3of4
Elite
 
Registriert seit: 14.11.1999
Alter: 40
Beiträge: 1.429


Standard

OK dass nächste Problem:

Hier der Source, und die Fehlermeldungen dazu gleich in Quotes darunter.

Ps: vorher hatte ich einfach eine } gelöscht
Zitat:
#include<stdio.h>
#include<stdlib.h>

struct node{
int Katnr;
int Ktostand;
struct node *prev;
struct node *next;
};
void show(struct node *point);
void insert(int zahl1, int zahl2, struct node *point);
struct node *search(struct node *point, int Zahl1);
void delete(int zahl1, struct node *root);
void save(char pfad[], struct node *root);
struct node *load(char pfad[]);
void main(){
struct node *root=NULL, *found;
char ein[130];
int z1,z2,loop=1,menu;
struct node *temp;
while(loop){
printf("\n\n0 Datensatz eingeben\n1 Datensatz suchen\n2 Datensatz l”schen\n3 Datens„tze ausgeben\n4 Speichern\n5 Laden\n6 Beenden\n Eingabe: ");
menu=atoi(gets(ein));
switch(menu)
{
case 0:
printf("\nBitte Katalognummer eingeben: ");
z1=atoi(gets(ein));
printf("\nBitte Kontostand eingeben: ");
z2=atoi(gets(ein));
if(root==NULL){
root=malloc(sizeof(struct node));
root->Katnr=z1;
root->Ktostand=z2;
root->next=NULL;
root->prev=NULL;
}
else insert(z1,z2,root);
getch();
break;
case 1:
printf("\nBitte Katalognummer eingeben: ");
z1=atoi(gets(ein));
temp=search(root, z1);
if(temp!=NULL){
printf("\nKatalognummer: %d gefunden, Kontostand: %d",z1,temp->Ktostand);
}
else{
printf("\nKatalognummer: %d nicht gefunden, bitte Eingabe berprfen",z1);
}
getch();
break;
case 2:
printf("\nBitte Katalognummer eingeben: ");
z1=atoi(gets(ein));
delete(z1,root);
getch();
break;
case 3:
show(root);
getch();
break;
case 4:
printf("\nBitte Pfad und Dateiname eingeben");
gets(ein);
save(ein,root);
getch();
break;
case 6: loop=0;
break;
default: printf("Bitte gltige Zahl eingeben"); getch();
}
}
}
void insert(int zahl1, int zahl2, struct node *point){
if(point->next==NULL){
struct node *new;
new = (struct node *)malloc(sizeof(struct node));
new->Katnr=zahl1;
new->Ktostand=zahl2;
new->prev=point;
new->next=NULL;
point->next=new;
}
else
insert (zahl1, zahl2, point->next);
}

void show(struct node *point){
if(point!=NULL){
printf("\nKatalognummer: %3d Guthaben: %3d",point->Katnr,point->Ktostand);
}
else printf("Keine Daten vorhanden");
if(point->next!=NULL){
show(point->next);
}
}
struct node *search(struct node *point, int zahl1){
if(point->Katnr==zahl1){
return point;
}
else if(point->next!=NULL){
return search(point->next, zahl1);
}
else{
return NULL;
}
}
void delete(int zahl1, struct node *root){
struct node *temp = search( root , zahl1);
if(temp!=NULL){
struct node *tempprev=temp->prev;
struct node *tempnext=temp->next;
printf("Katalognummer %d mit Kontostand %d wurde gel”scht",temp->Katnr,temp->Ktostand);
tempprev->next=tempnext;
tempnext->prev=tempprev;
if(temp==root) root=tempnext;
/*free(temp->Katnr);
free(temp->Ktostand);*/
free(temp);
}
else
printf("\nKatalognummer %d nicht gefunden, bitte Eingabe berprfen",zahl1);
}
void save(char name[], struct node *root){
FILE *fp=fopen(name,"w");
struct node *point=root;
if(fp!=NULL){
while(point!=NULL){
fseek(fp,0L,SEEK_END);
fwrite((void *) &point, sizeof(struct node),1,fp);
point=point->next;
}
printf("\nIn Datei: ");
puts(name);
printf("gespeichert.");
}
else{
printf("\nFehler beim Erstellen der Datei");
}

}
struct node *load(char pfad[]){
struct node *root, *temp;
int n=0;
FILE fp=fopen(pfad,"r");
Zitat:
Error D:\WINDOWS\DESKTOP\LIST.CPP 146: Illegal structure operation in function load
if(fp!=NULL){
Zitat:
Error D:\WINDOWS\DESKTOP\LIST.CPP 147: Illegal structure operation in function load
fseek(fp,0L,SEEK_END);
Zitat:
Error D:\WINDOWS\DESKTOP\LIST.CPP 148: Type mismatch in parameter 'stream' in fseek

Warning D:\WINDOWS\DESKTOP\LIST.CPP 148: Possible use of 'fp' before definition
root=temp=(struct node *)malloc((size_t)ftell(fp));
Zitat:
Error D:\WINDOWS\DESKTOP\LIST.CPP 149: Type mismatch in parameter 'stream' in function load
Warning D:\WINDOWS\DESKTOP\LIST.CPP 149: Possible use of 'fp' before definition
rewind(fp);
while(fread(p,sizeof(struct node),1,fp){
Zitat:
Error D:\WINDOWS\DESKTOP\LIST.CPP 150: Type mismatch in parameter 'stream' in function load
p+=1;
n++;
}
temp=root;
while(n--){
printf("\nKatalognummer: %d Kontostand: %d",p->Katnr,p->Ktostand);
}
}
else
printf("Fehler beim Lesen der Datei, bitte Eingabe berprfen");
}
}
____________________________________
Resistantium est futilius
3of4 ist offline   Mit Zitat antworten