|
发表于 2002-8-29 18:15:50
|
显示全部楼层
先写好sh程序,并在shell下可执行。在C中可以用system()执行它。
举例如下:
$cat mysh
-----------------------------------------------------------------
#!sh
#
# this test program for C call
echo "this is shell"
-------------------------------------------------------------------
cat callsh.c
/*********************************************
*
* the program is call myshell
*
*********************************************/
#include <stdio.h>
int main()
{
printf("\nthis is C program!\n");
system("mysh");
return 0;
} |
|