Schau, mal, da dampft es ein bißchen:
wenn du init_tap anspringst mit der Adresse von TABELLE, ist diese Adresse NULL (TABELLE *t1=NULL)
Der malloc will nun sein ergebnis dorthin schreiben (nach pt->tab) und das ist im Nirwana.
SCHREIBE folgendes (übergenau für meschuggene Compiler)
void init_tap(TABELLE *pt,int max)
{
pt->max = max;
pt->anzahl = 0;
pt->tab = (STUDENT *) malloc(pt->max*sizeof(STUDENT));
}
int main()
{
TABELLE t1; // KEIN * , die Structur ist tatsächlich da
init_tap((TABELLE *)&t1,5); // &t1 ist die Adresse von tabelle
...
VARIANTE 2:
int main(){
TABELLE *t1 = (TABELLE *)malloc(sizeof(TABELLE)); // malloc #1
init_tap((TABELLE *)t1,5); // malloc #2
Du wirst sehen, dann klappts auch mit der Nachbarin
mfg Robert
Lesezeichen