I am writing a simple function in C, the purpose of which is to take a 6-bit number, work out the first 3 bits and based on this return "r", "w" or "o".
However, when compiling, I get this warning: "return makes an integer from a pointer without a cast." Then, when I run the program, I find that the function returns a strange character, which is definitely not one of the three that I follow.
What's going on here? Thanks in advance.
Here is my function:
char
readorwrite(int opcode)
{
if (opcode >> 3 == 4) {
return "r";
} else if (opcode >> 3 == 5) {
return "w";
} else {
return "o";
}
}
source
share