illegal use of floating point

I kept getting Illegal use of character on the line that checks if a variable is empty or null.

Does anyone know why this happened?

the error points here:

though it worked before i just dont know whats causing this error.

changed the code now the errors are too few parameters for function sinfa.

i only want to pass one parameter at a time to this function, is it possible or do i have to create another function to do that so that i can cater to them individually?

4 Answers 4

Error appears because you’re comparing float with string literal, ie:

You can only do a comparison of float with a numeric/float literal, ie:

Recall that there’s no such concept as NULL / uninitialized for primitive type such as float. Instead they typically default to 0.

Hence having the following means f value will be literal 0

«» is not a number. You cannot compare a number to it.

The error appears because you try to compare a literal string to a float value.

Your test for empty strings is also wrong. To check if a string is null or empty you should use the following code (assuming that type of fp is char * ):

The sinfa function doesn’t have a valid prototype. Add type specifiers to the parameters num1 , num2 in the function definition.

And according to the Standard the prototype of the main function should be either

I suppose you’re trying to check if there were errors during scanf input conversion. In order to do that you should inspect the result of scanf and check the gloval error state using the ferror function (or check the errno value directly).

I am getting an illegal use of floating point error in my programme:

I have no idea why this error is appearing, it would be great if someone could help me with this

1 Answer 1

pow is a function that returns a double . and the C++ modulo operator % works only with integer numbers. That’s because the mathematical modulo operator is defined for integers. Hence the illegal use .

Besides, you use the check variable without initialization. Initialize all you variables before use, in order to avoid further surprises.

Here are some other corrections to do:

check = number before the first for loop.

Finally, try to find another way to get the digits of the number, without using pow . There are simple ways using consecutive integer division.

Совсем запутался с нагромаждением циклов в расчётах по формулам
дефузии (теплопродности):

Во всех случаях где встречается z возникает ошибка:

E2060 Illegal use of floating point

Оцените статью