I tried finding this question, but all the other questions don't relate to my problem.
My issue: I have something like 0xFreeFoodU where I have to get specific positions and either flip them or make them 1s or 0s.
So for example, bits in position 2, 6, 10, 14, 18, 22 , 26, and 30 should be unchanged, whereas the bits in positions 3, 7, 11, 15, 19, 23, 27, and 31 should be changed to 1. I don't wanna post my entire prompt bc I don't wanna cheat and get someone else to do my hw for me. But giving me an answer to at least one of these will help millions.
This is bit manipulation. But I have no clue how to manipulate specific bits in specific positions. :(
EDIT I cant upload a full program; its too long. But I have a main function where I call the function I need. The function should just ideally have return and so-on; so far I have
return val_num ^ 0x22222222U; But I should be adding to it. I only want help with how to set certain bits to 1 and 0. Is masking required?