Zelený je lopuch, fotbal to je hra...Lopuch.cz
template<int n> void fce(int pole[n]) { int a; a = sizeof(pole); }
void add (A **array) { A* newA = malloc(sizeof(A)); newA->structB.value = 12345; array[1] = newA; }
#include "stdio.h" #include "stdlib.h" struct b { int value; }; struct a { struct b structB; }; typedef struct a A; void add (A **array) { A newA; newA.structB.value = 12345; array[1] = &newA; } A *pointers[5]; int main (void) { add (&*pointers); printf("%d\n", pointers[1]->structB.value); // Vypise 12345 -> spravne printf("%d\n", pointers[1]->structB.value); // Vypise nesmysl (pravdepodobne adresu v pameti), proc? getchar(); return 0; }