projects
/
my-code
/
beginners.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f9fdaf4
)
added string2bin
author
hackbard
<hackbard>
Thu, 13 Mar 2003 13:42:32 +0000
(13:42 +0000)
committer
hackbard
<hackbard>
Thu, 13 Mar 2003 13:42:32 +0000
(13:42 +0000)
string2bin.c
[new file with mode: 0644]
patch
|
blob
diff --git a/string2bin.c
b/string2bin.c
new file mode 100644
(file)
index 0000000..
3d8f928
--- /dev/null
+++ b/
string2bin.c
@@ -0,0
+1,15
@@
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ unsigned char *s=argv[1];
+ int i,j;
+ for(j=0;j<strlen(s);j++) {
+ for(i=7;i>=0;i--) {
+ printf("%s%d%s",i==7?"|":"",
+ s[j]&(1<<i)?1:0,
+ i==0?"|\n":"|");
+ }
+ }
+return 23;
+}