Question: I'm writing a piece of code in C for `pocketsphinx` module of `freeswitch` to save the utterance (waveform or audio) to a file. I receive the audio as a `void *data` and its `unsigned int len` and I have to save it as a `RAW` (or `PCM`) file (no headers).
How do I do this?

I've tried this:

```
FILE *_file;
int16_t *_data;
_data = (int16_t *) data;
_file=fopen("utterance","ab");
fwrite(data, sizeof(_data[0]), sizeof(_data)/sizeof(_data[0]), _file);
fclose(_file);
_file=NULL;

```

It doesn't work (Maybe I'm not doing it right?). I've also found `libvlc` and `libsndfile` but haven't found any function that'd serve me.
Anyone here have a simple example/tutorial on this?

I'm working on C, VS2010, Win8.1 (x64)

Answer: 
you shouldn't use `sizeof(_data)/sizeof(_data[0])` when \_data is a pointer; `sizeof(_data)` is how many bytes the pointer `_data` takes

```
size_t valueCount = sampleCount * channelCount;
FILE *_file;
int16_t *_data;
_data = (int16_t *) data;
_file=fopen("utterance","ab");
fwrite(data, sizeof(_data[0]), valueCount, _file);
fclose(_file);
_file=NULL;

```

you could also use

```
fwrite(data, 1, len, _file);

```
The major issue with this is that you use `sizeof(_data) / sizeof(_data[0])` as an attempt to compute the length of the array. However, since `_data` is of type `int16_t *`, i.e. just a pointer, then `sizeof(_data)` will return the size of a pointer (which, in your case, is just 8). You'll need some other way to pass in the length of the array.