簡單使用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地址
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/5009.html
標籤:C
