Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************
- * Bindump 1.0 (Binary Dump) *
- * Author: Michael Warren *
- * Date: Sat Mar 23 2019 *
- * License: Michael Warren FSL *
- *******************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <errno.h>
- int main( int argc, char **argv ){
- FILE *fp;
- int c;
- if( !(fp = fopen( argv[1], "r" )) ){
- perror( argv[0] );
- exit( errno );
- }
- while( (c = fgetc( fp )) != EOF ){
- uint8_t b = 0x80;
- while( b ){
- if( b & c ) putchar( '1' );
- else putchar( '0' );
- b >>= 1;
- }
- putchar( ' ' );
- if( ftell( fp ) % 8 == 0 ) putchar ( '\n' );
- }
- fclose( fp );
- putchar( '\n' );
- return 0;
- }
Add Comment
Please, Sign In to add comment