I have this following piece of code.
I am getting segfaulted when I iterate on *attachmentsArray after the first iteration, even though size==3 .
What am I doing wrong here?
void secondary(char** array, long size)
{
*array = (char*)malloc(size*sizeof(char));
for(int i = 0; i < size; i++)
{
*array[i] = '.';
}
}
void main()
{
char* attachmentsArray;
long size = 3;
secondary(&attachmentsArry, size);
}
secondary()supposed to beattachmentsArray? That seems to be the name used in the function body.size==10? Please post a Minimal, Reproducible Example.