error: invalid operands to binary expression ('char *' and 'double')

printf ("Give me a postive number you want change for.\n");
scanf ("%f", &total_float);
roundf ("%f" * 100.0 = "%d", &total_float, &total_int);
printf ("%d"), &total_int;

I've reviewed my code to the below but I still can't figure out the invalid operand error that generated from line 3.

printf ("Give me a postive number you want change for.\n");
scanf ("%f", &total_float);
("%f" * 100.0 = "%f"), &total_float, &total_float;
total_int = roundf (total_float);
printf ("%d", total_int);

and if I try it this way I get the error that its nonassignable:

total_float * 100.0 = total_float;

Changed it to :

total_float = total_float * 100

and the code works now.

  • 1
    What exactly are you trying to do? Please improve your question with more details. Are you trying to use printf() maybe?
    – ChrisG
    Jul 21, 2015 at 11:00

1 Answer 1


Line 1: OK

Line 2: If you have declared total_float as a float before this code snippet it's OK.

Line 3: That is not the correct use of roundf(). I would suggest you use man roundf on a terminal to find the correct use. I could give it to you but that way you are not gonna learn how to solve your problems yourself. I'll give you just the signature of the functions, which is float roundf(float x).

Line 4: I think you want to write printf("%d", total_int);. Again you have to declare total_int beforehand and make the assignment.

I would suggest you rewatch the lesson videos, as I don't think you have really understood how to use these functions and you won't be able to follow the next lessons unless you do.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .