Siemens Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
void FunPassDoublePointer(char *chErrArr[])
{
// here by incrementing the chErrArr pointer you can get strings corresponding to errors
chErrArr++;
}
void main()
{
char chArr1[] = "Error 1 occured";
char chArr2[] = "Error 2 occured";
char chArr3[] = "Error 3 occured";
char *chErrorArr[] = {chArr1,chArr2,chArr3};
char **pchArr = NULL;
pchArr = chErrorArr;
void FunPassDoublePointer(char *chErrArr[]);
FunPassDoublePointer(pchArr);
}
I think you can use calloc here.
- Prashanth January 28, 2014As malloc will initialize this array to garbage value, once memory is created.
But calloc will initialized to NULL