zoukankan      html  css  js  c++  java
  • <cstdlib>下system函数的使用

    int system(const char* command)

    调用系统命令执行command。如果command为空,返回处理器是否可用(0不可用)。

    使用例子

    #include <stdlib.h> //or #include <cstdlib>
    system("dir");


    这提供了与系统交互的接口,方便我们使用shell命令。

    本人访问一个页面,本要使用curl,要设置很多参数,注意线程安全等,使用linux 的wget命令就方便多了。

    string str="wget -q -O /dev/null http://www.baidu.com";
    system(str.c_str());


    补:cstdlib包含了c/c++最常用的系统函数,如malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、srand()、exit()

  • 相关阅读:
    3.21上午
    3.17下午
    2017.4.14-morning
    2017.4.13-afternoon
    2017.4.13-morning
    2017.4.12-afternoon
    2017.4.12-morning
    2017.4.11-afternoon
    2017.4.11-morning
    2017.4.10-afternoon
  • 原文地址:https://www.cnblogs.com/whuqin/p/4982027.html
Copyright © 2011-2022 走看看