DEC.CPP: Porovnání verzí

Z Delphi & Pascal (česká wiki)
Skočit na navigaci Skočit na vyhledávání
(Vytvorená stránka „ file dec.cpp by Dustin Caldwell (dustin@gse.utah.edu): #include <dos.h> #include <stdio.h> #include <stdlib.h> void helpdoc(); main() { ...“)
 
 
(Není zobrazena jedna mezilehlá verze od stejného uživatele.)
Řá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 <stdio.h>
 
+
  #include <stdlib.h>
#include <dos.h>
+
#include <stdio.h>
+
  void helpdoc();
#include <stdlib.h>
+
 
+
  main()
void helpdoc();
+
  {
 
+
          FILE *fp;
main()
+
          unsigned char ch, c;
{
+
        FILE *fp;
+
          if((fp=fopen(_argv[1], "rb"))==NULL)            /* open file to read */
 
+
          {
        unsigned char ch, c;
+
                  printf("cannot open file %s\n",_argv[1]);
 
+
                  helpdoc();
        if((fp=fopen(_argv[1], "rb"))==NULL)            /* open file to read */
+
                  exit(-1);
        {
+
          }
                printf("cannot open file %s\n",_argv[1]);
+
                helpdoc();
+
          c=0;
                exit(-1);
+
          ch=fgetc(fp);
        }
+
 
+
          while(!feof(fp))                        /* loop for whole file */
        c=0;
+
          {
        ch=fgetc(fp);
+
                  printf("%u\t", ch);            /* print every byte's decimal equiv. */
 
+
                  c++;
        while(!feof(fp))                        /* loop for whole file */
+
                  if(c>8)                                /* print 8 numbers to a line */
        {
+
                  {
                printf("%u\t", ch);            /* print every byte's decimal equiv. */
+
                          c=0;
                c++;
+
                          printf("\n");
                if(c>8)                                /* print 8 numbers to a line */
+
                  }
                {
+
                        c=0;
+
                  ch=fgetc(fp);
                        printf("\n");
+
          }
                }
+
 
+
          fclose(fp);                    /* close up */
                ch=fgetc(fp);
+
  }
        }
+
 
+
  void helpdoc()                  /* print help message */
        fclose(fp);                    /* close up */
+
  {
}
+
          printf("\n  Binary File Decoder\n\n");
 
+
          printf("\n Syntax:  dec binary_file_name\n\n");
void helpdoc()                  /* print help message */
+
          printf("by Dustin Caldwell  (dustin@gse.utah.edu)\n\n");
{
+
          printf("This is a filter program that reads a binary file\n");
        printf("\n  Binary File Decoder\n\n");
+
          printf("and prints the decimal equivalent of each byte\n");
 
+
          printf("tab-separated. This is mostly useful when piped \n");
        printf("\n Syntax:  dec binary_file_name\n\n");
+
          printf("into another file to be edited manually.  eg:\n\n");
 
+
          printf("c:\>dec sonata3.mid > son3.txt\n\n");
        printf("by Dustin Caldwell  (dustin@gse.utah.edu)\n\n");
+
          printf("This will create a file called son3.txt which can\n");
        printf("This is a filter program that reads a binary file\n");
+
          printf("be edited with any ascii editor. \n\n");
        printf("and prints the decimal equivalent of each byte\n");
+
          printf("(rec.exe may also be useful, as it reencodes the \n");
        printf("tab-separated. This is mostly useful when piped \n");
+
          printf("ascii text file).\n\n");
        printf("into another file to be edited manually.  eg:\n\n");
+
          printf("Have Fun!!\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]]
 
[[Standard MIDI Format]]

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