Issue
I have been given a list of the following check box containing all possible solutions to the question of choosing all true answers equivalent to O_RDWR on Ubuntu 14.04 LTS. according to this list below
O_RDONLY
1
2
3
1 << 1
3 & 2
3 | 2
O_WRONLY
(O_RDONLY + O_WRONLY)
(O_RDONLY | O_WRONLY)
(O_RDONLY & O_WRONLY)
(O_RDONLY && O_WRONLY)
(O_RDONLY << 1)
(O_WRONLY << 1)
0
I have chosen 2 and (O_RDONLY | O_WRONLY) but am still getting errors
anyone who can help me with this?
Solution
Look into bitwise operators.
O_RDWR is defined in fcntl.h and is equals to 2.
O_WRONLY = 1
O_RDONLY = 0
1 = 1
2 = 2
3 = 3
1 << 1 = 2
3 & 2 = 2
3 | 2 = 3
O_WRONLY = 1
(O_RDONLY + O_WRONLY) = 1
(O_RDONLY | O_WRONLY) = 1
(O_RDONLY & O_WRONLY) = 0
(O_RDONLY && O_WRONLY) = 0
(O_RDONLY << 1) = 1
(O_WRONLY << 1) = 2
0 = 0
Answered By - user14607366 Answer Checked By - Timothy Miller (WPSolving Admin)