Estoy tratando de hacer una matriz de tamaño variable en c.¿Por qué una matriz de longitud variable grande tiene un valor fijo -1 incluso si está asignada a C?
La matriz sigue volviendo a tener un valor de -1.
Lo que quiero hacer es hacer una matriz de tamaño size
y luego añadirle valor incrementalmente. ¿Qué estoy haciendo mal?
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;
}
duplicado de http://stackoverflow.com/questions/448844/variable-sized-arrays-in-c – alvin
El código se ve bien, pero el tamaño es grande. ¿Estás seguro de que tu programa tiene 18MB de stack para usar? –
@Steve. Me estaba confundiendo la cantidad de elementos que quiero que contenga mi matriz y el tamaño real de la misma. – dubbeat