I have one doubt, could it be possible to create one
typedef struct whatever
and then if one function requires:
void function(char * something);
when you call the function in main program write:
function((char *) whatever);
is that correct?
Thank you!
There is no defined behavior for casting a structure to any pointer type. Very likely your compiler would reject such a cast, but if it accepted it then the resulting behavior is unlikely to be useful.
Moreover, you cannot pass a type (i.e. whatever
) as a function argument.
You could conceivably pass a pointer to an object of your type:
int main() {
whatever my_whatever = { 0 };
function((char *) &my_whatever);
}
That will work, for some definition of "work". Whether it is sensible depends on the implementation of function()
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments