Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- void showHex (char* file); //shows a file in hex code
- int main (int argc, char* argv [])
- {
- char filename [256];
- if (argc>1)
- {
- strcpy (filename, argv [1]);
- }
- else
- {
- printf ("Dateiname: ");
- fgets (filename, 255, stdin); //entspricht gets
- }
- showHex (filename);
- return 0;
- }
- void showHex (char *file)
- {
- FILE *datei;
- char text;
- datei = fopen (file, "r");
- if (datei != NULL)
- {
- while((text=getc(datei)) != EOF)
- {
- printf("%x", text);
- }
- fclose (datei);
- }
- else
- {
- fclose (datei);
- printf ("Datei nicht gefunden!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment