Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

what is "invalid operands to binary & (have ‘char *’ and ‘int’)"

+3 votes
asked Mar 2 by itay shani (150 points)

i cant understand what is 

invalid operands to binary & (have ‘char *’ and ‘int’)

2 Answers

0 votes
answered Mar 3 by Fluffyfuffy (330 points)
What language are you using?
commented Mar 3 by Peter Minarik (69,270 points)
That is an error message from a C/C++ compiler.
0 votes
answered Mar 3 by Peter Minarik (69,270 points)

You cannot apply binary and (&) operator on the types int and char *.

So your code is "similar" to this below:

#include <stdio.h>

int main()
    char * myString = "test";
    int i = 3;
    if (i & myString) // main.c:7:11: error: invalid operands to binary & (have ‘int’ and ‘char *’)
        printf("Hello World");

    return 0;

How to fix this? Review your code, what you're doing is incorrect.

If you really want to apply a binary operation on a memory address, cast it to an (unsigned) int before.

If you want a more specific answer, you'll need to share your code.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.