I recently encountered this code, and I'm confused, what is it for?
What does it mean in the C programming language, to type cast a variable to void
data type? What does this accomplish?
If an expression such as a type cast, or an addition is performed, and the result is not immediately assigned to some variable, then that result gets lost. Why should you ever want to do that? It seems like a useless expression.
The code sample:
int main(int argc, char *argv[])
{
/* void unused vars */
(void) argc;
(void) argv;
// more code here
return 0;
}
It seems the author was not using these variables, but why cast them to void
data type? You might as well cast them to int
data type.
void
really do?int main(
void)
.