Why the following printf of the buffer in the readWav() causes segmentation fault just after printing the first row to the screen? Are there any issues with the use of pointer in printf("%d\t %f\n", i, *buffer[i]);?
#include <stdio.h>
#include "sndfile.h"
int readWav(const char *const fname, long *numFrames, int *sRate, float **buffer);
int main(int argc, char *argv[])
{
int sRates, sRatem, ret;
long nSamples = 0, nSamplem;
float *datas, *datam;
ret = readWav(argv[1], &nSamples, &sRates, &datas);
if (ret != 0) {
printf("Error\n");
return 1;
}
------
-----
}
int readWav(const char *const fname, long *numFrames, int *sRate, float **buffer)
{
// Open sound file
SF_INFO sndInfo;
-----
----
for (i=0; i < sndInfo.frames ; i++) {
printf("%d\t %f\n", i, *buffer[i]);
}
// Are there any issues with the use of pointer?
sf_close(sndFile);
return(0);
}