Which of these answers are the equivalent of O_RDWR on Ubuntu 14.04 LTS?

0

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

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More