projects
/
my-code
/
beginners.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
added string2bin
[my-code/beginners.git]
/
string2bin.c
1
#include <stdio.h>
2
#include <string.h>
3
4
int main(int argc, char **argv) {
5
unsigned char *s=argv[1];
6
int i,j;
7
for(j=0;j<strlen(s);j++) {
8
for(i=7;i>=0;i--) {
9
printf("%s%d%s",i==7?"|":"",
10
s[j]&(1<<i)?1:0,
11
i==0?"|\n":"|");
12
}
13
}
14
return 23;
15
}