I have written following sample code to demonstrate my problem
#include
#include
using namespace std;
void f (char*** a)
{
It's because of the operator precedence, where the array-indexing operator []
have higher precedence than the dereference operator *
.
So the expression *a[0]
is really, from the compilers point of view, the same as *(a[0])
, which is not what you want.
You have to explicitly add parentheses to change the precedence:
(*a)[0] = ...
a[0], a[1] are char, and they have a value in them, dereferencing that value will obviously cause a segmentation fault. What you may want to do is:
(*a)[...]
dereference 'a' which is a pointer, this will give u an array.