|
-
November 18th, 2009, 07:56 AM
#1
problems appending to array (dynamic array size)
Hello-
i'm having problems appending data to the end of a dynamic array, i'm reading in data from a wave file and then getting the number of frames and creating a dynamic array with that memory size however in my loop the data doesn't appear to add to the array, here is a sample, any ideas what might be going wrong? (i should note, i've been doing python for a little while and this is my first jump into the world of c+ and i miss some of the list methods )
buf = (int *) malloc(num_items*sizeof(int));
num = sf_read_int(sf,buf,num_items);
sf_close(sf);
rawWaveDataArray = new int[num_items];
int arraySize = sizeof(rawWaveDataArray);
printf("the array size is: %d \n", arraySize);
printf("Read %d items\n", num);
/* Write the data to filedata.out. */
out = fopen("filedata.out","w");
for (i = 0; i < num; i += c)
{
for (j = 0; j < c; ++j)
fprintf(out,"%d ",buf[i+j]);
rawWaveDataArray[j-1] = buf[i+j];
fprintf(out,"\n");
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|