Warum tut sich eine große variable-Länge-array hat einen festen Wert -1 zugeordnet, auch wenn in C?

Ich versuche eine variable sized array in c.

Array hält wieder ein Wert von -1.

Was ich will zu tun ist, um ein array der Größe size und dann schrittweise Werte hinzufügen. Was mache ich falsch?

int size = 4546548;

UInt32 ar[size];
//soundStructArray[audioFile].audioData = (UInt32 *)malloc(sizeof(UInt32) * totalFramesInFile);
//ar=(UInt32 *)malloc(sizeof(UInt32) * totalFramesInFile);
for (int b = 0; b < size; b++)
{
    UInt32 l = soundStructArray[audioFile].audioDataLeft[b];
    UInt32 r = soundStructArray[audioFile].audioDataRight[b];
    UInt32 t = l+r;
    ar[b] = t;
}
Duplikat von stackoverflow.com/questions/448844/variable-sized-arrays-in-c
Code sieht OK, aber die Größe ist groß. Sind Sie sicher, dass Ihr Programm hat 18MB stack zu verwenden?
Ich war immer verwirrt, wie viele Artikel ich will, dass mein array zu halten und die tatsächliche Größe.

InformationsquelleAutor dubbeat | 2010-11-24

Schreibe einen Kommentar