20080219-C语言中system函数的用法

以下内容为转载 http://blog.chinaunix.net/u1/34183/showart_409595.html

函数名: system
功 能: 发出一个DOS命令
用 法: int system(char *command);
程序例:

#include
#include

int main(void)
{
printf("About to spawn command.com and run a DOS command/n");
system("dir"); //这里就是DOS下的dir命令
return 0;
}

 

system函数用法
 
 

 

 

system  

--------------------------------------------------------------------------------


Executes a shell command


#include <stdlib.h>
int system ( const char *s );



The system( ) function passes a command line addressed by the pointer argument s to an operating system shell. If s is a null pointer, the function returns true (a nonzero value) if a command processor is available to handle shell commands, and 0 or false if not.

How the system executes a command, and what value the system( ) function returns, are left up to the given implementation. The command may terminate the program that calls system( ), or have unspecified effects on its further behavior.

Example
if ( system( NULL ))
  system( "echo /"Shell: $SHELL; process ID: $$/"");
else
  printf( "No command processor available./n" );



This example is not portable, but on certain systems it can produce output like this:

Shell: /usr/local/bin/bash; process ID: 21349

 

例子:

删除文件

system("rm -f $TMP_DIR/xxx.dat >& /dev/null");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值