Add file organization
This commit is contained in:
parent
ccddc6a1af
commit
1795f0287b
9 changed files with 140 additions and 26 deletions
|
|
@ -7,14 +7,21 @@ void binaire(unsigned int n, char s[]);
|
|||
int main(int argc, char **argv){
|
||||
FILE *file;
|
||||
char buffer;
|
||||
int cursor,c;
|
||||
int cursor,c,i;
|
||||
file=fopen("text.txt","rb");
|
||||
char text_b[5][BIN_MAX+1];
|
||||
i=0;
|
||||
// EOF : End Of File
|
||||
while((c=fgetc(file))!=EOF){
|
||||
char sb[BIN_MAX+1];
|
||||
binaire(32,sb);
|
||||
binaire(c,sb);
|
||||
printf("%s\n",sb);
|
||||
}
|
||||
for(i=0;i<5;i++){
|
||||
for(int j=0;j<BIN_MAX;j++){
|
||||
printf("%c",text_b[i][j]);
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -22,7 +29,6 @@ int main(int argc, char **argv){
|
|||
void binaire(unsigned int n, char s[]){
|
||||
/*
|
||||
Décomposition binaire d'un entier (<BIN_MAX) et place celle-ci dans une chaîne de caractères passée en argument (s)
|
||||
|
||||
*/
|
||||
assert(n>=BIN_MAX);
|
||||
s[BIN_MAX]= '\0';
|
||||
|
|
@ -37,4 +43,8 @@ void binaire(unsigned int n, char s[]){
|
|||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
int k;
|
||||
for(k=BIN_MAX-i-1;k>=0;k--){
|
||||
s[k]= '0';
|
||||
}
|
||||
}
|
||||
Reference in a new issue