witam,
mam problem z programem, kompiluje sie on pod windowsem, natomiast pod linuksem wyskakuje blad "naruszenie ochrony paimeci". W czym moze tkwic problem?
przesylam kod
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int **tab;
int **tabkol;
int a=0, b=0, i, n;
int wsp_test;
int petl;
char kon = '\0', lol;
printf ("jaki chcesz rozmiar swiata?");
scanf ("%d", &n);
tab=(int **)calloc((n+2),sizeof(int *));
for(i=0;i<(n+2);i++){
tab[i]=(int*)calloc((n+2),sizeof(int));
}
tabkol=(int **)calloc((n+2),sizeof(int *));
for(i=0;i<(n+2);i++){
tabkol[i]=(int*)calloc((n+2),sizeof(int));
}
for (a; a<(n+2); a++, b=0)
{
for (b; b<(n+2); b++)
{
if (a==0 || b==0) *(*(tab+a)+b) = 0;
if (a==(n+1) || b==(n+1)) *(*(tab+a)+b) = 0;
}
}
a=0; b=0;
for (a; a<(n+2); a++, b=0)
{
for (b; b<(n+2); b++)
{
if (a==0 || b==0) *(*(tabkol+a)+b) = 0;
if (a==(n+1) || b==(n+1)) *(*(tabkol+a)+b) = 0;
}
}
a=1; b=1;
for (a; a<(n+1); a++, b=1)
{
for (b; b<(n+1); b++)
{
scanf("%d", &*(*(tab+a)+b)) ;
}
}
system ("cls");
a=1; b=1;
for (a; a<(n+1); a++, b=1)
{
printf ("\n");
for (b; b<(n+1); b++)
{
printf("%d ", *(*(tab+a)+b)) ;
}
}
scanf ("%c", lol);
while (kon!='k')
{
printf ("\n\n");
a=1; b=1;
for (a; a<(n+1); a++, b=1)
{
for (b; b<(n+1); b++)
{
if (*(*(tab+(a-1))+(b-1))) wsp_test++ ;
if (*(*(tab+(a-1))+b)) wsp_test++ ;
if (*(*(tab+(a-1))+(b+1))) wsp_test++ ;
if (*(*(tab+a)+(b+1))) wsp_test++ ;
if (*(*(tab+(a+1))+(b+1))) wsp_test++ ;
if (*(*(tab+(a+1))+b)) wsp_test++ ;
if (*(*(tab+(a+1))+(b-1))) wsp_test++ ;
if (*(*(tab+a)+(b-1))) wsp_test++ ;
if (wsp_test == 3) *(*(tabkol+a)+b) = 1;
if (wsp_test == 2) *(*(tabkol+a)+b)=*(*(tab+a)+b);
if (wsp_test!= 3 && wsp_test!=2) *(*(tabkol+a)+b)=0;
wsp_test=0;
}
}
a=1; b=1;
kon = getchar();
if (kon == 'z') {zapi(tab, n);}
for (a; a<(n+1); a++, b=1)
{
printf ("\n");
for (b; b<(n+1); b++)
{
printf("%d ", *(*(tabkol+a)+b)) ;
}
}
a=1; b=1;
for (a; a<(n+1); a++, b=1)
{
for (b; b<(n+1); b++)
{
*(*(tab+a)+b) = *(*(tabkol+a)+b);
}
}
}
}
zapi(int **tab, int n)
{
int a = 1, b=1;
FILE *filePtr;
char nazwa[200];
printf ("Podaj nazwe pliku wraz ze sciezka:\n");
scanf ("%s", &nazwa);
filePtr = fopen(nazwa, "w");
for (a; a<(n+1); a++, b=1)
{
for (b; b<(n+1); b++)
{
fprintf(filePtr, "%d ", *(*(tab+a)+b));
}
fprintf (filePtr, "\n");
}
fclose(filePtr);
printf ("Dane zostaly zapisane");
getchar();
system("cls");
}
z gory dzieki za pomoc