I got that error which cant figure out. I look over related questions but I dont give a meaning someone show me which part do I need to fix?
[Error] void value not ignored as it ought to be
My codes
void getEdge(char str[],char *token){
*token = strtok(str, "_,");
while (token != NULL )
{
// printf("%s\n", token);
token = strtok(NULL, "_,");
}
}
void getEdge(char str[],char *token);
int main () {
char arr[] = "A_B_10,A_F_6,B_C_6,C_B_10,D_A_3";
char *toke;
char result;
result = getEdge(arr,toke);
printf("%s\n",result);
}
Check this line
result = getEdge(arr,toke);
you're trying to capture the return value of a function for which the return type is void
.
Remember, void
is an incomplete type, and it's not compatible with any other type (in this case, LHS is char
), hence the compiler rightly complains.
That said,
*token = strtok(str, "_,");
inside the function also does not look very correct. Check the types there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With