summaryrefslogtreecommitdiffstats
path: root/2/6.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-01 21:44:14 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-01 21:44:14 +0800
commitc800a6727d58641f97db0f24a6e3ad1076a4eec7 (patch)
tree6fff8e6ebebf8e85e037878a54630f6982390c1e /2/6.c
parentb289ca6aad91532fd6598be112f656f51fffcfc7 (diff)
downloadk&r-exercises-c800a6727d58641f97db0f24a6e3ad1076a4eec7.tar.gz
Clean up.
Diffstat (limited to '2/6.c')
-rw-r--r--2/6.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/2/6.c b/2/6.c
index bf8cf2f..bb8c1de 100644
--- a/2/6.c
+++ b/2/6.c
@@ -1,21 +1,6 @@
#include <stdio.h>
-unsigned setbits(unsigned x, int p, int n, unsigned y);
-
-int main(int argc, char *argv[]) {
- int p, n;
- unsigned x, y;
-
- p = 5;
- n = 3;
- x = 0;
- y = 7;
-
- printf("New bit field: %x\n", setbits(x, p, n, y));
-
- return 0;
-}
-
+/* sets the n bits of x starting at p to rightmost n bits of y */
unsigned setbits(unsigned x, int p, int n, unsigned y) {
unsigned yLO, yLOA, xUnset, xPrime;