#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student
{
int nralb;
char imie[ 999 ];
};
int main()
{
char * k;
int i, n, j, p;
start:
printf( "%s", "ilu? " );
scanf( "%d", & n );
if( n > 0 && n < 100 )
{ struct Student * ptr;
ptr = calloc( n, sizeof( struct Student ) );
for( j = 0; j < n; j++ )
{
printf( "%s", "Imie? " );
scanf( "%s", k );
strcpy( ptr[ j ].imie, k );
printf( "%s", "Numer? " );
scanf( "%d", & p );
ptr[ j ].nralb = p;
}
for( i = 0; i < n; i++ )
{
printf( "Imie: %s\n", ptr[ i ].imie );
printf( "Numer albumu: %d\n", ptr[ i ].nralb );
}
}
else
{
printf( "%s", "nieprawidoa liczba\n" );
goto start;
}
return 0;
}
Program kompiluje się i działa do momentu podania imienia, zaraz potem wyskakuje "program przestał działać". Problem w tym, że ponieważ kompiluje się bez problemu, to nie mam pojęcia co jest z tą zmienną "p" nie tak.