Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. char s[255] = "JSON String value";
  2. //for each character, print it's binary aoutput
  3. int i,c,power;
  4. for ( i=0 ; s[i]!='' ; i++ )
  5. {
  6. //c holds the character being converted
  7. c = s[i];
  8. //for each binary value below 256 (because ascii values < 256)
  9. for ( power=7 ; power+1 ; power-- )
  10. //if c is greater than or equal to it, it is a 1
  11. if ( c >= (1<<power) )
  12. {
  13. c -= (1<<power); //subtract that binary value
  14. printf("1");
  15. }
  16. //otherwise, it is a zero
  17. else
  18. printf("0");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement