DEC.CPP: Porovnání verzí

Z Delphi & Pascal (česká wiki)
Skočit na navigaci Skočit na vyhledávání
 
Řádek 1: Řádek 1:
 
   /*  file  dec.cpp
 
   /*  file  dec.cpp
 
 
   by  Dustin Caldwell    (dustin@gse.utah.edu)
 
   by  Dustin Caldwell    (dustin@gse.utah.edu)
 
 
   */
 
   */
 
+
 
 
 
   #include <dos.h>
 
   #include <dos.h>
 
   #include <stdio.h>
 
   #include <stdio.h>
 
   #include <stdlib.h>
 
   #include <stdlib.h>
 
+
 
   void helpdoc();
 
   void helpdoc();
 
+
 
   main()
 
   main()
 
   {
 
   {
 
           FILE *fp;
 
           FILE *fp;
 
 
           unsigned char ch, c;
 
           unsigned char ch, c;
 
+
 
           if((fp=fopen(_argv[1], "rb"))==NULL)            /* open file to read */
 
           if((fp=fopen(_argv[1], "rb"))==NULL)            /* open file to read */
 
           {
 
           {
Řádek 24: Řádek 20:
 
                   exit(-1);
 
                   exit(-1);
 
           }
 
           }
 
+
 
           c=0;
 
           c=0;
 
           ch=fgetc(fp);
 
           ch=fgetc(fp);
 
+
 
           while(!feof(fp))                        /* loop for whole file */
 
           while(!feof(fp))                        /* loop for whole file */
 
           {
 
           {
Řádek 37: Řádek 33:
 
                           printf("\n");
 
                           printf("\n");
 
                   }
 
                   }
 
+
 
                   ch=fgetc(fp);
 
                   ch=fgetc(fp);
 
           }
 
           }
 
+
 
           fclose(fp);                    /* close up */
 
           fclose(fp);                    /* close up */
 
   }
 
   }
 
+
 
   void helpdoc()                  /* print help message */
 
   void helpdoc()                  /* print help message */
 
   {
 
   {
 
           printf("\n  Binary File Decoder\n\n");
 
           printf("\n  Binary File Decoder\n\n");
 
 
           printf("\n Syntax:  dec binary_file_name\n\n");
 
           printf("\n Syntax:  dec binary_file_name\n\n");
 
 
           printf("by Dustin Caldwell  (dustin@gse.utah.edu)\n\n");
 
           printf("by Dustin Caldwell  (dustin@gse.utah.edu)\n\n");
 
           printf("This is a filter program that reads a binary file\n");
 
           printf("This is a filter program that reads a binary file\n");

Aktuální verze z 20. 12. 2012, 18:29

 /*  file  dec.cpp
 by  Dustin Caldwell    (dustin@gse.utah.edu)
 */

 #include <dos.h>
 #include <stdio.h>
 #include <stdlib.h>

 void helpdoc();

 main()
 {
         FILE *fp;
         unsigned char ch, c;

         if((fp=fopen(_argv[1], "rb"))==NULL)            /* open file to read */
         {
                 printf("cannot open file %s\n",_argv[1]);
                 helpdoc();
                 exit(-1);
         }

         c=0;
         ch=fgetc(fp);

         while(!feof(fp))                        /* loop for whole file */
         {
                 printf("%u\t", ch);             /* print every byte's decimal equiv. */
                 c++;
                 if(c>8)                                 /* print 8 numbers to a line */
                 {
                         c=0;
                         printf("\n");
                 }

                 ch=fgetc(fp);
         }

         fclose(fp);                     /* close up */
 }

 void helpdoc()                  /* print help message */
 {
         printf("\n   Binary File Decoder\n\n");
         printf("\n Syntax:  dec binary_file_name\n\n");
         printf("by Dustin Caldwell  (dustin@gse.utah.edu)\n\n");
         printf("This is a filter program that reads a binary file\n");
         printf("and prints the decimal equivalent of each byte\n");
         printf("tab-separated. This is mostly useful when piped \n");
         printf("into another file to be edited manually.  eg:\n\n");
         printf("c:\>dec sonata3.mid > son3.txt\n\n");
         printf("This will create a file called son3.txt which can\n");
         printf("be edited with any ascii editor. \n\n");
         printf("(rec.exe may also be useful, as it reencodes the \n");
         printf("ascii text file).\n\n");
         printf("Have Fun!!\n");
 }

Standard MIDI Format