I'm trying to figure out how buffers work in C. First off, I'm trying to create a buffer which holds integers. The thing is, I don't know how to access values in the buffer. I was thinking about using calloc( ) instead of malloc( ).
Here's my current code:
1 2 3 4 5 6 7 8 9 10 11
#include <cstdlib>
int main( )
{
int *Buffer( ( int * )malloc( sizeof( int ) ) );
free( Buffer );
Buffer = NULL;
return 0;
}
So basically, I'm accessing elements in the buffer like an array using the subscript operator? So what is the difference between calloc( ) and malloc( )?