Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Xcode use help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Jpramos007" data-source="post: 661868" data-attributes="member: 55468"><p>anyone know how I can add a space between my printout in binary. This is my code and the for loop will give me the correct readout I just cant get the output to put a space in between every four characters.#include <stdio.h></p><p> </p><p></p><p></p><p>// int andfx(int i, int mask);</p><p> int count;</p><p> int i = 0x1b53;</p><p>int mask = 0x8000;</p><p>int j;</p><p></p><p></p><p></p><p></p><p></p><p></p><p>int main (void) </p><p>{</p><p>printf("Hex value = %x,\t",i);</p><p>printf("Binary value=");</p><p>for (count =0;count<=16;count++)</p><p></p><p></p><p></p><p>{</p><p>if (i&mask)</p><p></p><p></p><p></p><p>printf("1");</p><p>else </p><p>printf("0");</p><p>mask = mask >> 1;</p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p>} </p><p></p><p></p><p></p><p></p><p></p><p></p><p>printf("\n");</p><p></p><p></p><p></p><p></p><p> return 0;</p><p>}</p></blockquote><p></p>
[QUOTE="Jpramos007, post: 661868, member: 55468"] anyone know how I can add a space between my printout in binary. This is my code and the for loop will give me the correct readout I just cant get the output to put a space in between every four characters.#include <stdio.h> // int andfx(int i, int mask); int count; int i = 0x1b53; int mask = 0x8000; int j; int main (void) { printf("Hex value = %x,\t",i); printf("Binary value="); for (count =0;count<=16;count++) { if (i&mask) printf("1"); else printf("0"); mask = mask >> 1; } printf("\n"); return 0; } [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Xcode use help
Top