#inlcude<stdlib.h>

int system(const char* command)

功能:在已经运行的程序中调用另一个外部程序

参数:外部可执行程序的名字

返回值:不同系统的返回值不一样

实例程序

 

#include<stdio.h>
#include<stdlib.h>

int main()
{
   printf("before sys\n");
  
   system("ls");
   //system("ls -alh");

//查看执行程序所在目录下的所有目录内容

//Linux下(运行一个程序需要加./)

// system("./hello");

//windows(运行一个程序不需要加./)

// system("hello");  // system("calc"); //计算器

//hello为该程序目录下的可执行文件,程序会在执行到system的时候,调用hello这个程序

printf("after sys\n");

return 0;
}

结果

System函数的使用说明的更多相关文章

  1. 关于linux下system()函数的总结

    导读 曾经的曾经,被system()函数折磨过,之所以这样,是因为对system()函数了解不够深入.这里必须要搞懂system()函数,因为有时你不得不面对它. 先来看一下system()函数的简单 ...

  2. C语言中的system函数参数及其作用

    函数名: system 功   能: 发出一个DOS命令  用   法: int system(char *command);  system函数已经被收录在标准c库中,可以直接调用 system() ...

  3. linux下使用fork,exec,waitpid模拟system函数

    代码如下: #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include &l ...

  4. Linux system函数详解

    system 功能:system()函数调用"/bin/sh -c command"执行特定的命令,阻塞当前进程直到command命令执行完毕 原型 int system(cons ...

  5. Linux system 函数的一些注意事项

    在日常的代码编程中 , 我们可以利用system  函数去调用一些我们自己想调用的命令 , 并获取他的返回值. 函数的原型如下: int system(const char *command); 上一 ...

  6. 关于system函数的安全性漏洞

    当以一个普通用户去执行  设置-用户ID 为root的程序时,如果再次用了system函数时,被system函数所执行的那个程序具有 有效-用户ID 为root的风险(虽然真实用户还是普通用户),这也 ...

  7. C语言中system()函数的用法总结(转)

    system()函数功能强大,很多人用却对它的原理知之甚少先看linux版system函数的源码: #include <sys/types.h> #include <sys/wait ...

  8. system 函数

    相关函数:fork, execve, waitpid, popen 头文件:#include <stdlib.h> 定义函数:int system(const char * string) ...

  9. system函数

    system两层含义: 1.正确退出后.还需要再判断,操作成功或者操作失败. 2.错误退出. #include <stdio.h> #include <stdlib.h> #i ...

随机推荐

  1. Java基础系列 - 数组、二维数组、对象数组

    package com.test2; public class demo2 { public static void main(String[] args) { /** * 一维数组使用 */ //数 ...

  2. Tkinter 之Canvas画布

    一.参数说明 参数 作用 background(bg) 指定 Canvas 的背景颜色 borderwidth(bd) 指定 Canvas 的边框宽度 closeenough 指定一个距离,当鼠标与画 ...

  3. vue 路由传参的三种方法

    API在这里  https://router.vuejs.org/guide/essentials/navigation.html 第一种传参 通过路由属性中的name来确定匹配的路由,通过param ...

  4. class与computed一起应用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 查看日志tail命令

    打开终端,连接jboss: 命令: tail -f -n 500 /var/log/wildfly/wrapper.log

  6. ListView中的Item不能点击的解决方法

    有时,为了实现某种功能,在Android程序中会考虑在ListView的每一个Item中添加一个Button(或ImageButton等). 但是,这样会出现一个问题: 当同时设置了Button的on ...

  7. .net core 资料网站 和 开源项目

    https://www.xcode.me/ 1.ASP.NET Core模块化前后端分离快速开发框架介绍之1.开篇 2.https://www.cnblogs.com/laozhang-is-phi/ ...

  8. apache配置https重定向

    apache配置https重定向 一.总结 一句话总结: 网上找不到答案的原因是因为没有精准的描述问题,没有把问题描述清楚:尽量把关键词描述清楚 1.apache将80端口重定向443的具体步骤(在 ...

  9. lua字符串处理(string库用法)

    原文地址http://www.freecls.com/a/2712/f lua的string库是用来处理字符串的,基础函数如下 string.byte(s [, i [, j]]) string.by ...

  10. 算法习题---4.3救济金发放(UVa133)

    一:题目 (n< )个人站成一圈,逆时针编号为1~n.有两个官员,A从1开始逆时针数,B从n开始顺时针数.在每一轮中,官员A数k个就停下来,官员B数m个就停下来(注意有可能两个官员停在同一个人上 ...