This commit is contained in:
2026-03-31 16:57:45 +02:00
parent fc780b0220
commit d38af389b6
19 changed files with 202 additions and 17 deletions

View File

@@ -2,8 +2,13 @@
// apisz poprawną wersję.
int *stworzTablice(int n) {
int tab[n]; // (1) — co jest nie tak?
// int tab[n]; // (1) — co jest nie tak? // alokuje na stosie - błąd
int *tab = new int[n]; // alokujemy na stercie
for (int i = 0; i < n; i++)
tab[i] = i;
return tab; // (2) — co jest nie tak?
return tab; // (2) — co jest nie tak? // poprzednio zwracaliśmy adres lokalnej zm
// ennej, teraz zwracamy adres danych zaalokowanych na stercie
// i jest super
}
int main() { return 0; }