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