Skip to content

Instantly share code, notes, and snippets.

@KrzaQ

KrzaQ/lepie.c Secret

Created April 14, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KrzaQ/af69526aeab0b14ec55a to your computer and use it in GitHub Desktop.
Save KrzaQ/af69526aeab0b14ec55a to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#define N 10 // liczba wierszy
#define M 10 // liczba kolumn
void zerowanie(int** plansza);
int _tmain(int argc, _TCHAR* argv[])
{
int** plansza, i; // tworzenie wskaznika do int
plansza = (int**)malloc(N * sizeof(int*));
for (i = 0; i < N; ++i)
;
{
plansza[i] = (int*)malloc(M * sizeof(int)); //tworzenie dynamicznej tablicy o wymiarach N x M
}
zerowanie(plansza);
for (i = 0; i < N; ++i) {
free(plansza[i]);
}
free(plansza); // Zwolnienie pamieci zarezerwowanej dla planszy
system("PAUSE");
return 0;
}
//*********************************************************************************************************************
void zerowanie(int** plansza)
{
int i, j;
for (i = 0; i < N; i++)
for (j = 0; j < M; j++) {
plansza[i][j] = 0; // zapisywanie zer w tablicy Tutaj wyrzuca mi błąd
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment