當前位置:首頁 » 編程語言 » c語言dos命令

c語言dos命令

發布時間: 2023-06-26 13:35:55

A. c語言如何用dos命令編譯運行

找不到程序是
PATH
的問題
可以直接在
Visual
Studio
Command
Prompt
里運行
或者打開
cmd
後執行一下
VC
目錄下的
vcvarsall.bat

B. 在C語言中如何使用dos命令

用system()函數
原型:int
system(char
*cmd)
包含在dos.h下(VC
包含在stdlib.h)

定時關機
程序:
#include<stdio.h>
#include<dos.h>
#include<string.h>
void
main()
{
char
s[30]="shutdown
-s
-t
";
char
*p;
printf("please
input
how
many
seconds
you
want
to
wait
:
");
scanf("%s",p);
strcat(s,p);
system(s);
}
需要注意的是,上面的程序需在Turbo
C小編譯,在VC環境下會提示error
C2065:
'system'
:
undeclared
identifier
可以改為:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int
main()
{
char
p[100]="shutdown
-s
-t
";
char
s[20];//注意這里不能寫成*s否則即使調試成功,程序寫無法正常運行!
int
str;
int
ch;
printf("請輸入
等待時間
(秒):");
scanf("%s",s);
strcat(p,s);
system(p);
return
0;
}
一旦編譯成功後就可以在工程文件夾下找到生成的*.exe
文件,以後就不用那麼麻煩的鍵入命令啦,呵呵……
如果想取消關機,可另外在寫一個程序:
#include<stdio.h>
#include<dos.h>
#include<string.h>
void
main()
{
char
s[30]="shutdown
-a
";
system(s);
}
二合一,那叫一個方便啊,哦也!!!

C. c語言中什麼指令可以關閉dos窗口

DOS命令用法: int system(char *command); system函數在標准函數庫stdlib.h中,可以直接調用,dos中的退出命令:exit。解決方法如下:

1、首先創建一個C++控制台應用。

D. 如何在C語言中調用DOS命令

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

int main()
{

char comStr1[]="zyxwvutsrqponmlkjihgfedc";//搜索GHO文件並執行安裝
char ch[] = "if exist %c:\\ghost\\xp32.gho a:\\ghost.exe -nousb -noide -clone,mode=pload,src=%c:\\ghost\\xp32.gho:1,dst=1:1 -crcignore -sure -rb\n";
char ch1[200];
int i;
for(i = 0; comStr1[i] != '\0'; i++)
{
sprintf(ch1, ch, comStr1[i], comStr1[i]);

system(ch1);
}

return 0;

}

熱點內容
javawsdl2java 發布:2025-02-12 02:25:21 瀏覽:366
java默認許可權 發布:2025-02-12 02:25:20 瀏覽:655
演算法預測用戶 發布:2025-02-12 02:24:44 瀏覽:390
舊電腦搭建網路列印伺服器 發布:2025-02-12 02:09:45 瀏覽:648
c語言順序表基本操作 發布:2025-02-12 02:09:41 瀏覽:887
安卓光遇怎麼開三檔畫質華為 發布:2025-02-12 01:55:51 瀏覽:193
微信哪裡能找到登陸游戲的密碼 發布:2025-02-12 01:54:22 瀏覽:591
php獲取伺服器ip地址 發布:2025-02-12 01:54:12 瀏覽:578
對象存儲和nas哪個好 發布:2025-02-12 01:50:34 瀏覽:445
phpmulticurl 發布:2025-02-12 01:41:58 瀏覽:70