diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..1df4412 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/bit_print.c b/bit_print.c index 870a431..cc9fd81 100644 --- a/bit_print.c +++ b/bit_print.c @@ -9,15 +9,15 @@ Prints out the bits contained in an integer value. void bit_print(int a) { - int i; + int itr; int n = sizeof(int) * CHAR_BIT; /* find size of ints for this macine */ int mask = 1 << (n - 1); /* set mask to 1000000...000 */ - for(i = 1; i <= n; ++i) + for(itr = 1; itr <= n; ++i) { putchar(((a & mask) == 0) ? '0' : '1'); - a <<= 1; /* shift over by one bit */ - if(i % CHAR_BIT == 0 && i < n) + a <<= 1; /* shift over by 1 bit */ + if(itr % CHAR_BIT == 0 && itr < n) putchar(' '); } putchar('\n');