Gra Eurobiznes - problem z usuwaniem tablicy

0

Witam. Otóż posiadam taki kod :

#include "stdafx.h"
#include <conio.h>
#include <malloc.h>
#include <stdlib.h>
#include <cstdlib>
int** tworzplan(int gracz,int size);
int* tworzplan1(int size);
int* tworzbank(int gracz);
void wpiszwart(int **plan,int *bank,int gracz);
void drukplan(int **plan,int *plan1,int gracz,int size);
void info(int *bank,int gracz);
int ruch(int **plan,int size,int rzut1,int y);
void spr(int **plan,int *bank,int temp,int y,int *plan1);
void usun(int **plan,int *plan1,int *bank,int size);
//////////
int _tmain(int argc, _TCHAR* argv[])
{
  int size,gracz;
  int **plan;
  int *plan1;
  int *bank;
  int rzut=0;
  int koniec=0;
  int temp,i,rzut1;
  do
  {
  printf("Podaj rozmiar planszy:");
  scanf("%d",&size);
  if(size<20||size>40) printf("Podales zla wartosc, sproboj jeszcze raz !\n");
  }
  while(size<20||size>40);

  do
  {
  printf("\nPodaj ilosc graczy");
  scanf("%d",&gracz);
  if(gracz<2||gracz>4) printf("Podales zla wartosc, sproboj jeszcze raz !\n");
  }while(gracz<2||gracz>4);

  plan=tworzplan(gracz,size);
  plan1=tworzplan1(size);
  bank=tworzbank(gracz);
  wpiszwart(plan,bank,gracz);
  do
  {
  system("cls");
  rzut1=(rand()%5)+1;
  int y=(rzut%gracz);
  printf("\n\n\nRzuca koscia gracz:%d\n",y+1);
  printf("Wylosowano:%d",rzut1);
  printf("\n");
  rzut++;
  temp=ruch(plan,size,rzut1,y);
  drukplan(plan,plan1,gracz,size);
  info(bank,gracz);
  for(i=0;i<gracz;++i)
  {
  if(bank[i]<=0) koniec=1;
  }
  spr(plan,bank,temp,y,plan1);
  }while(koniec!=1);
  usun(plan,plan1,bank,size);
  _getch();
return 0;
}

int** tworzplan(int gracz,int size)
{
  int **plan;
  int i;
  plan=(int**)calloc(gracz,sizeof(int*));
  for(i=0;i<size;++i)
  {
                     *(plan+i)=(int*)calloc(size,sizeof(int));
  }
  return plan;
}

int* tworzplan1(int size)
{
    return (int*)calloc(size,sizeof(int));
}

int* tworzbank(int gracz)
{
    return (int*)calloc(gracz,sizeof(gracz));
}

void wpiszwart(int **plan,int *bank,int gracz)
{
    int i;
    for(i=0;i<gracz;++i)
    {
        plan[i][0]=1;
        bank[i]=1000;
    }
}
void drukplan(int **plan,int *plan1,int gracz,int size)
{
    int i,x;
    for(i=0;i<gracz;++i)
  {
                      for(x=0;x<size;++x)
                      {
                      if((plan[i][x])==1) printf("%d",i+1);
                      else printf(" ");
                      }
                      printf("\n");
  }
  for(i=0;i<size;++i)
  {
                     if(plan1[i]>0) printf("%d",plan1[i]);
                     else printf("-");
  }
  printf("\n");
}

void info(int *bank,int gracz)
{
    int i;
      for(i=0;i<gracz;++i)
  {
                      printf("%d:$%d\t",i+1,bank[i]);
  }
printf("\n");
}

int ruch(int **plan,int size,int rzut1,int y)
{
  int x;
  int temp;
  for(x=0;x<size;++x)
  {
  if(plan[y][x]==1)
  {
                   temp=((x+rzut1)%size);
                   plan[y][x]=0;
                   plan[y][temp]=1;
                   break;
  }
  }
  return temp;
}

void spr(int **plan,int *bank,int temp,int y,int *plan1)
{
  char wybor;
  if(plan1[temp]>0&&plan1[temp]!=y+1)
  {
                   printf("Pole nalezy do przeciwnika, placisz $10\n");
                   bank[y]=bank[y]-10;
                   _getch();
  }
  else  if(plan1[temp]==0)
  {
              printf("Pole nalezy do banku, chcesz je kupic[t/n] ?\n");
              wybor=_getch();
              switch(wybor)
              {
                           case 't':
                                bank[y]=bank[y]-100;
                                plan1[temp]=y+1;
                                break;
                           default: break;
              }
              printf("\n\n\n");
  }
}

void usun(int **plan,int *plan1,int *bank,int size)
{
  int z;
  for(z=0;z<size;++z)
  {
  free(plan[z]);
  }
  free(plan);
  free (plan1);
  free (bank);  
} 

Mój problem polega na tym ze przy usuwaniu tablicy 'plan' (wywołanie funkcji usuń w programie )pojawiają się dla mnie niezidentyfikowane blędy a mianowicie :
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\AppPatch\AcLayers.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\userenv.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\profapi.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\winspool.drv', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\mpr.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'eurobiznes.exe': Loaded 'ImageAtBase0x4aad0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4aad0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4aaf0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4aaf0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x49ea0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x49ea0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4ac50000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4ac50000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a850000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a850000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4ab60000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4ab60000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a650000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a650000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4acc0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4acc0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a930000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a930000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a2d0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a2d0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a840000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a840000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4ac90000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4ac90000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a590000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a590000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4ab30000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4ab30000'
'eurobiznes.exe': Loaded 'ImageAtBase0x49d70000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x49d70000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a8b0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a8b0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a2d0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a2d0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a090000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a090000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a4d0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a4d0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a190000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a190000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4ace0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4ace0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a1c0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a1c0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4aa40000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4aa40000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a170000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a170000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a100000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a100000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4aca0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4aca0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x49ee0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x49ee0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a650000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a650000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a1c0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a1c0000'
'eurobiznes.exe': Loaded 'ImageAtBase0x4a7c0000', Loading disabled by Include/Exclude setting.
'eurobiznes.exe': Unloaded 'ImageAtBase0x4a7c0000'
HEAP[eurobiznes.exe]: Invalid address specified to RtlValidateHeap( 00720000, 00723730 )
Windows has triggered a breakpoint in eurobiznes.exe.

This may be due to a corruption of the heap, which indicates a bug in eurobiznes.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while eurobiznes.exe has focus.

The output window may have more diagnostic information.
The program '[5180] eurobiznes.exe: Native' has exited with code 0 (0x0).

Mój kompilator to VS 2010. Pozdrawiam

0

The program '[5180] eurobiznes.exe: Native' has exited with code 0 (0x0).

Przecież program zakończył się bez błędów.

0

Użyłeś złego rozmiary przy wypełnianiu tablicy plan:
plan=(int


**<code>)calloc(<b>gracz</b>,sizeof(int*));
  for(i=0;i<**size**;++i)

> *(plan+i)
Dlaczego nie `plan[i]`?

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0