⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.doc

📁 hello everybody. good lucky to you
💻 DOC
📖 第 1 页 / 共 5 页
字号:
                     /* detect and initialize graphix */
                        graphdriver = DETECT;
                        initgraph(&graphdriver, &graphmode, "..");
                        errorcode = graphresult();
                        if (errorcode != grOk)
                        {
                           printf("graphics error:
                     %s\n",grapherrormsg(errorcode));
                           exit(1);
                        }
                        settextjustify(CENTER_TEXT, CENTER_TEXT);



                                   - 9 -






                        settextstyle(GOTHIC_FONT, HORIZ_DIR, 4);
                        outtextxy(getmaxx()/2,getmaxy()/2,
                                  "Borland Graphics Interface (BGI)");
                     /* press a key to terminate */
                        getch();
                     /* shut down graphics system */
                        closegraph();
                        return(0);
                     }



===========================================================================
CPP: The preprocessor
===========================================================================

    CPP produces a  Often, when the compiler reports an error inside a
  list (in a file)  macro or an include file, you can get more information
     of a C source  about what the error is if you can see the include
  program in which  files or the results of the macro expansions. In many
 include files and  multi-pass compilers, a separate pass performs this
    #define macros  work, and the results of the pass can be examined.
         have been  Since Turbo C++ uses an integrated single-pass compil-
   expanded. It is  er, we provided CPP to supply the first-pass
    not needed for  functionality found in other compilers.
    normal compil-
       ations of C  You use CPP just as you would use TCC, the standalone
         programs.  compiler. CPP reads the same TURBOC.CFG file for
                    default options, and accepts the same command-line
                    options as TCC.

                    The TCC options that don't pertain to CPP are simply
                    ignored by CPP. To see the list of arguments handled by
                    CPP, type cpp at the DOS prompt. To see how those
                    arguments work, see Chapter 5 in the Programmer's
                    Guide.

                    With one exception, the file names listed on the CPP
                    command line are treated like they are in TCC, with
                    wildcards allowed. The exception to this is that all
                    files are treated as C source files. There is no
                    special treatment for .OBJ, .LIB, or .ASM files.

                    For each file processed by CPP, the output is written
                    to a file in the current directory (or the output
                    directory named by the -n option) with the same name as
                    the source name but with an extension of .I.




                                  - 10 -






                    This output file is a text file containing each line of
                    the source file and any include files. Any preproces-
                    sing directive lines have been removed, along with any
                    conditional text lines excluded from the compile.
                    Unless you use a command-line option to specify other-
                    wise, text lines are prefixed with the file name and
                    line number of the source or include file the line came
                    from. Within a text line, any macros are replaced with
                    their expansion text.

        Important!  The resulting output of CPP cannot be compiled because
                    of the file name and line number prefix attached to
                    each source line.


    CPP as a macro  =======================================================
      preprocessor
                    The -P option to CPP tells it to prefix each line with
                    the source file name and line number. If you give it -
                    P- (turning this option off), CPP omits this line
                    number information. With this option turned off, CPP
                    can be used as a macro preprocessor; the resulting .I
                    file can then be compiled with TC or TCC.


        An example  =======================================================

                    The following simple program illustrates how CPP
                    preprocesses a file, first with -P selected, then with
                    -P-.

                    Source file: HELLOAJ.C
                     #define NAME "H.R. Floyd"
                     #define BEGIN {
                     #define END   }

                     main()
                     BEGIN
                        printf("%s\n", NAME);
                     END

                    Command line used to invoke CPP as a preprocessor:
                       CPP HELLOAJ.C

                    Output:
                     HELLOAJ.c 1:
                     HELLOAJ.c 2:
                     HELLOAJ.c 3:



                                  - 11 -






                     HELLOAJ.c 4:
                     HELLOAJ.c 5: main()
                     HELLOAJ.c 6: {
                     HELLOAJ.c 7:    printf("%s\n","H.R. Floyd");
                     HELLOAJ.c 8: }

                    Command line used to invoke CPP as a macro
                    preprocessor:
                       CPP -P- HELLOAJ.C

                    Output:
                     main()
                     {
                        printf("%s\n","H.R. Floyd");
                     }



===========================================================================
GREP: A text-search utility
===========================================================================

                    GREP (Global Regular Expression Print) is a powerful
                    text-search program derived from the UNIX utility of
                    the same name. GREP searches for a text pattern in one
                    or more files or in its standard input stream.

                    Here's a quick example of a situation where you might
                    want to use GREP. Suppose you wanted to find out which
                    text files in your current directory contained the
                    string "Bob". You would issue the command

                       grep Bob *.txt

                    and GREP would respond with a list of the lines in each
                    file (if any) that contained the string "Bob". Because
                    the default for GREP is to ignore case, the strings
                    "bob" and "BoB" would also be considered matches. You
                    can use options to make your search case sensitive.

                    GREP can do a lot more than match a single, fixed
                    string. In the section that follows, you'll see how to
                    make GREP search for any string that matches a
                    particular pattern.







                                  - 12 -






      Command-line  =======================================================
            syntax
                    The general command-line syntax for GREP is

                      grep [options] searchstring [file(s) ... ]

                    options consist of one or more letters, preceded by a
                    hyphen (-), that let you change various aspects of
                    GREP's behavior.

                    searchstring gives the pattern to search for.

                    file(s) tells GREP which files to search. (If you don't
                    specify a file, GREP searches its standard input; this
                    lets you use GREP with pipes and redirection.) If you
                    find that the results of your GREP are longer than one
                    screen, you can redirect the output to a file. For
                    example, you could use this command

                       GREP "Bob" *.txt >gfile

                    which searches all files in the current directory that
                    end with .TXT, then places the results in a file called
                    GFILE. (You can name this file anything you like.)
                    Then, use your word processor (or Turbo C++'s editor)
                    to access GFILE to read the results of the search.

                    The command

                       GREP ?

                    prints a brief help screen showing GREP's command-line
                    options, special characters, and defaults. (See the
                    description of the -u command-line option for
                    information on how to change GREP's defaults.)


      GREP options  =======================================================

                    In the command line, options are one or more single
                    characters preceded by a hyphen (-). Each individual
                    character is a switch that you can turn on or off: A
                    plus symbol (+) after a character turns the option on;
                    a hyphen (-) after the character turns the option off.
                    The + sign is optional; for example, -r means the same
                    thing as -r+. You can list multiple options





                                  - 13 -






                    individually (like this: -i -d -l), or you can combine
                    them (like this: -ild or -il, -d, and so on); it's all
                    the same to GREP.

                    Here are the GREP option characters and their meanings:


------------------------------------------------------------------------------
Option Meaning
------------------------------------------------------------------------------


  -c   Match Count only: Prints only a count of matching lines. For each file
       that contains at least one matching line, GREP prints the file name and
       a count of the number of matching lines. Matching lines are not
       printed. This option is off by default.

  -d   Search subdirectories: For each file specified on the command line,
       GREP searches for all files that match the file specification, both in
       the directory specified and in all subdirectories below the specified
       directory. If you give a file without a path, GREP assumes the files
       are in the current directory. This option is off by default.

  -i   Ignore case: GREP ignores upper/lowercase differences (case folding).
       When this option is on, GREP treats all letters a to z as identical to
       the corresponding letters A to Z in all situations. This option is on
       by default.

  -l   List file names only: Prints only the name of each file containing a
       match. After GREP finds a match, it prints the file name and processing
       immediately moves on to the next file. This option is off by default.

  -n   Line Numbers: Each matching line that GREP prints is preceded by its
       line number. This option is off by default.

  -o   UNIX output format: Changes the output format of matching lines to
       support more easily the UNIX style of command-line piping. All lines of
       output are preceded by the name of the file that contained the matching
       line. This option is off by default.

  -r   Regular expression search: The text defined by searchstring is treated
       as a regular expression instead of as a literal string. This option is
       on by default. This option is on by default.

       A regular expression is one or more occurrences of one or more
       characters optionally enclosed in quotes. The following symbols are
       treated specially:
        ^  start of line       $  end of line



                                  - 14 -






        .  any character       \  quote next character
        *  match zero or more  +  match one or more

        [aeiou0-9]             match a, e, i, o, u, and 0 thru 9
        [^aeiou0-9]            match anything but a, e, i, o, u, and 0 thru 9

  -u   Update options: GREP will combine the options given on the command line
       with its default options and write these to the GREP.COM file as the
       new defaults. (In other words, GREP is self-configuring.) This option
       allows you to tailor the default option settings to your own taste. If
       you want to see what the defaults are in a particular copy of GREP.COM,
       type

        GREP ?

       at the DOS prompt. Each option on the help screen will be followed by a
       + or a - depending on its default setting. This option is off by
       default.

  -v   Nonmatch: Prints only nonmatching lines. Only lines that do not contain
       the search string are considered to be nonmatching lines. This option
       is off by default.

  -w   Word search: Text found that matches the regular expression is
       considered a match only if the character immediately preceding and
       following cannot be part of a word. The default word character set
       includes A to Z, 0 to 9, and the underscore ( _ ). This option is off
       by default.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -