Pointers are good to have in your program. But also can be difficult to learn. “Indirection Requires Pointer Operand ('Int' Invalid)” is an error which occur because of a pointer. I give the cause and the solution of the error below.
The error message means that the programmer applied to dereference to a pointer to an integer. This means that a pointer is declared to a long integer. For instance, a pointer can only contain memory addresses, and thus the wrong length is applied to the pointer.
The following are some ways to solve the above error:
- passing a string representation of an integer into int
- passing a string representation of a float into float
- passing a string representation of an integer into float
- passing a float into int
- passing an integer into float
The method that can be used to solve the error is by converting the string to a numeric value. A string that contains a real value, not an integer should be created. The strategy invokes the float () builtin function that returns an actual value that can be attributed to the pointer.
This converts the string to a floating- point value which is converted to an integer through truncation and removing the fractional part. The value reduces the pointer from long integer thus the error will be solved.