I have a basic code where I can copy an array without problems. But when I introduce another kind of array, a more advanced variant which I think is called a dynamic array. Then my program crashes every time.
What am I doing wrong? What have I misunderstood?
Array tutorial: C Code Listing 7 - Array tutorial = [ Works ]
Code:
#include <stdio.h>
int main()
{
short age[4];
short same_age[4];
int i, j;
age[0]=23;
age[1]=34;
age[2]=65;
age[3]=74;
for(i=0; i<4; i++)
same_age[i]=age[i];
for(j=0; j<4; j++)
printf("%d\n", same_age[j]);
system("PAUSE");
return 0;
}
Improved code 1: = [ It still Works ]
xnN0TJ17 - Pastebin.com
Improved code 2: = [ It still Works ]
GCCALmpP - Pastebin.com
Improved code 3: = [ FAILED ]
When I uncomment the /* Copy array */ code then the program doesn't work anymore.
Why is it happening at this location? What am I doing wrong? What have I misunderstood?
DsQpH8AX - Pastebin.com