I have a function of that takes array of strings as input, add strings if its empty and then return the array. If the array is not empty, the array's content should be displayed.
If condition checks for emptiness by checking the size. My problem is that the size is always zero even when the array is not empty. And I know the array is not empty because I can print out its content.
This is my code:
char **check(char **words) {
if(sizeof (words) / sizeof (**words) == 0) {
words[0] = "vacation";
words[1] = "vaccaciones";
words[2] = "vancances"
}
else {
//do something else
}
}
It never goes into the else condition no matter what I try to do. I checked the array, it's not empty and the value for my if condition is always zero. What am I doing wrong?