I have a serious problem with this code:
double wczytanie(){
FILE *plik;
char znak;
int i=0;
int x=0;
float **tab;
char nazwapliku[100];
printf("Podaj nazwe pliku: ");
scanf("%s", nazwapliku);
plik = fopen(nazwapliku,"r");
while(!feof(plik)){
znak=fgetc(plik);
if(znak=='\n') {
i++;
}
}
tab=(float**)malloc(sizeof(float*)*3);
for(x=0;x<3;x++){
tab[x]=(float*)malloc(sizeof(float)*i);
}
rewind(plik);
for(x=0;x<=i;x++){
fscanf(plik,"%f %f %f", &tab[0][i], &tab[1][i], &tab[2][i]);
printf("%f %f %f\n", tab[0][i], tab[1][i], tab[2][i]);
}
fclose(plik);
The file is read properly, values are printed, but it crashes afterwards, returnig code 255, or 3221226356. When I removed the "fscanf" line it seemed to work without crashing, but well, it didn't read anything... How can I fix this? Any ideas what may cause the crash?