When I compile the following code (with -Wall), I get no warnings because I cast the *(str)++
to void type. However, if I do not cast that operation to void
type, the follow warning is put: warning: value computed is not used [-Wunused-value]
Is this the correct way to get rid of compiler warnings?
#include <stdio.h>
static void print(char *str)
{
while(*str) {
printf("%c\n", *str);
(void)*(str)++;
}
}
int main(void)
{
print("Hello");
return 0;
}