background image

如果在 DOS 提示符下, 按以下方式运行 EXAMPLE.EXE:
C:\example first_argument "argument with blanks" 3 4 "last but
one" stop!
注意: 可以用双引号括起内含空格的参数, 如本例中的: " argument
with blanks"和"Last but one")。
结果是这样的:
The value of argc is 7
These are the 7 command-linearguments passed to main:
argv[0]:C:\TURBO\EXAMPLE.EXE
argv[1]:first_argument
argv[2]:argument with blanks
argv[3]:3
argv[4]:4
argv[5]:last but one
argv[6]:stop!
argv[7]:(NULL)
The environment string(s) on this system are:
env[0]: COMSPEC=C:\COMMAND.COM
env[1]: PROMPT=$P$G /*视具体设置而定*/
env[2]: PATH=C:\DOS;C:\TC /*视具体设置而定*/
应该提醒的是: 传送 main()函数的命令行参数的最大长度为 128 

 

个字符 (包

括参数间的空格), 这是由 DOS 限制的。
函数名: matherr
功能: 用户可修改的数学错误处理程序
用法: int matherr(struct exception *e);
程序例:
/* This is a user-defined matherr function that prevents
any error messages from being printed.*/
#include
int matherr(struct exception *a)
{
return 1;
}
函数名: memccpy
功能: 从源 source 中拷贝 n 个字节到目标 destin 中
用法: void *memccpy(void *destin, void *source, unsigned char ch,
unsigned n);
程序例:
#include
#include
int main(void)
{
char *src = "This is the source string";
char dest[50];