C Language Graphics processing

Source: Internet
Author: User
Tags first string printf

Then talk about main () primary function

Every C program must have a main () function that can be placed somewhere in the program according to your hobby. Some programmers put it first, while others put it on the last side, no matter where it is, the following instructions are appropriate.

1. Main () parameter

During the turbo C2.0 boot process, pass the main () function three parameters: ARGC,ARGV and env.

* ARGC: Integer, for the number of command line arguments passed to main ().

* argv: Array of strings.

In the DOS 3.X version, argv[0] is the full path name for the program to run;

For the version below DOS 3.0, Argv[0] is an empty string (""). ARGV[1] is the first string after executing the program name on the DOS command line; argv[2] is the second string after executing the program name;

...

ARGV[ARGC] is null.

*env: An Fu string array. Each element of env[] contains a string of Envvar=value forms. Where Envvar is an environment variable such as path or 87. Value is the corresponding of Envvar

Values such as C:\DOS,C:\TURBOC (for path) or Yes (for 87).

The TurboC2.0 always passes these three parameters to the main () function, which can be described (or not) in the user's program, and if some (or all) of the parameters are described, they are

is a local variable for the main () subroutine. Please note that once you want to describe these parameters, you must press ARGC,ARGV, the order of Env, as shown in the following example:

main()
   main(int argc)
   main(int argc, char *argv[])
   main(int argc, char *argv[], char *env[])

The second of these is legal, but not common, because there are few cases in the program that use only argc, not argv[. The following provides an example program EXAMPLE.EXE that shows how to use three parameters in the main () function:

/*program name EXAMPLE.EXE*/
#include
#include
main(int argc,char *argv[],char *env[])
{
int i;
printf("These are the %d command-line arguments passed to \
main:\n\n", argc);
for(i=0; i<=argc; i++)
printf("argv[%d]:%s\n", i, argv[i]);
printf("\nThe environment string(s)on this system are: \
\n\n");
for(i=0; env[i]!=NULL; i++)
printf(" env[%d]:%s\n", i, env[i]);
}

If at a DOS prompt, run example.exe:c:\example first_argument "argument with blanks" 3 4 "last Butone" in the following manner stop!

Attention:

You can enclose parameters that contain spaces in double quotes, as in this example: "Argumentwith blanks" and "last but one". It should be reminded that the command to transfer the main () function

The maximum length of a row parameter is 128 characters (including spaces between parameters), which is restricted by DOS. Definition of text window the character screen function of Turbo C2.0 mainly includes text window size

Settings, window color setting, window text cleaning and input and output functions.

Turbo C2.0 The default defined text window is the entire screen, with a total of 80 columns (or 40 columns) of 25 rows of text units, each containing a character and a property, which is the ASCII character, which defines the color and strength of the character.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.