关于system的函数简单使用

简单使用system库函数

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

int main(void)
{
    printf("6s后关闭当前计算机!\n");
    
    system("shutdown -s -t 6 -f");
    
    return 0;
}

其中shutdown是系统的关机命令,具体的各个参数的含义可以在命令行下用shutdown/?查看该命令的帮助信息。Windows下一般的命令的具体用法都可以用类似的方法查看帮助信息。

system("date/T");		//查看系统日期
system("notepad.exe");	//启动Windows自带的记事本程序
system("cale.exe");		//启动Windows自带的计算机程序
system("gcc hi.c -o hi.exe & hi.exe");	//编译运行C程序,前提是当前目录下有这个C程序。&是系统支持的一种运行逻辑:命令1&命令2。即先执行命令1,然后在执行命令2
system("start https://www.cnblogs.com/zhouyt/");	//启动浏览器,打开指定的某个网页
system("del helloworld.exe");	//删除当前目录下helloworld.exe
system("ipconfig|find\"IPV4\"");	//显示当前机器的IP地址

posted @ 2020-07-18 11:04  周易通  阅读(433)  评论(0)    收藏  举报