c语言写一个关机程序,没有错误为什么运行不了。求指点。
在命令行里面自己打一下
shutdown
看是否可以识别到 还是一样提示
怀疑是环境问题。
也可以尝试改成
system("%windir%\\system32\\shutdown -s -t 50");
system函数的头文件是windiws.h
绛旓細鍦ㄥ懡浠よ閲岄潰鑷繁鎵撲竴涓 shutdown 鐪嬫槸鍚﹀彲浠ヨ瘑鍒埌 杩樻槸涓鏍锋彁绀 鎬鐤戞槸鐜闂銆備篃鍙互灏濊瘯鏀规垚 system("%windir%\\system32\\shutdown -s -t 50");
绛旓細1 浠ユ枃鏈柟寮忔墦寮鏂囦欢銆2 寰幆鐢╢scanf鏍煎紡鍖栬緭鍏ユ暟鎹埌鏁扮粍銆3 鍒ゆ柇fscanf鐨勮繑鍥炲硷紝濡傛灉鏄剧ず鍒拌揪鏂囦欢缁撳熬锛岄鍑鸿緭鍏ャ4 鍏抽棴鏂囦欢銆5 浣跨敤鏁版嵁銆備簩銆佷唬鐮佸疄鐜般傝瀹氭枃浠跺悕涓篿n.txt, 瀛樻湁涓绯诲垪鏁村瀷鏁版嵁锛屼互绌烘牸鎴栨崲琛屽垎闅斻備唬鐮佸彲浠ュ啓浣滐細include <stdio.h>int main(){int v[100];//寮涓涓冻澶熷ぇ...
绛旓細Please enter your desired automatic shutdown of time:12:29 鏂板姞浜嗕竴椤逛綔涓氾紝鍏朵綔涓 ID = 1
绛旓細1鍏虫満锛2閲嶅惎,ActionTime = "2005-11-7 13:42:30"'鍏虫満鎴栭噸鍚椂闂磃unction ShutDown()dim objShellSet objShell = WScript.CreateObject("Wscript.Shell")dim Applicationset Application = CreateObject("Shell.Application.1")Application.ShutdownWindows()dim ...
绛旓細姝ラ涓锛屽垱寤涓涓鏂板伐绋嬨傚湪椤堕儴鑿滃崟閫夋嫨"鏂囦欢"->"鏂板缓"->"Win32 Console Application"锛屽彇涓涓槗浜庤瘑鍒殑宸ョ▼鍚嶅瓧锛屼綅缃夊湪鏂逛究鏌ユ壘鐨勬枃浠跺す銆傛柊寤虹紪绋嬪伐绋嬫枃浠跺苟鍛藉悕 鎺ヤ笅鏉ワ紝涓轰簡瀛樻斁C璇█婧愮▼搴忥紝鍐嶆鐐瑰嚮"鏂囦欢"->"鏂板缓"->"C++ Source File"锛屼负鏂囦欢鍛藉悕锛岃嚦姝わ紝鍑嗗宸ヤ綔鍩烘湰瀹屾垚銆傞氳繃杩欐牱鐨...
绛旓細shutdown of time:");scanf("%s",shut);sprintf(b,"at %s shutdown -s",shut);system(b);} 杩愯瀹炰緥锛欻ello, Welcome to the TC automatic shutdown procedures Watermelon production Please enter your desired automatic shutdown of time:19:59 鏂板姞浜嗕竴椤逛綔涓氾紝鍏朵綔涓 ID = 1 ...
绛旓細1銆C璇█鍙互閫氳繃system鍑芥暟瀹炵幇璋冪敤绯荤粺鍛戒护(shell鍛戒护)銆俿ystem鍑芥暟澹版槑浜巗tdlib.h,褰㈠紡涓篿ntsystem(constchar*cmd);鍔熻兘涓烘墽琛宑md涓殑shell鎸囦护銆2銆佸湪windows涓锛屽叧鏈鍛戒护涓簊hutdown.鍏蜂綋璇存槑濡傚浘锛氭洿澶氫俊鎭紝鍙互鍛戒护琛屼笅杈撳叆shutdown/?鏌ョ湅銆3銆佷粠鍛戒护璇存槑涓婂彲浠ュ緱鐭ワ紝shutdown/s鍗冲彲瀹炵幇鍏虫満鏁堟灉銆4銆...
绛旓細system(" shutdown -s -t 0");鍏虫満 system("shutdown -l ");娉ㄩ攢 int flag;FILE *fp;fp=fopen("c:\\a.reg","wb");fprintf(fp,"%s\n","REGEDIT4");fprintf(fp,"%s","[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run]\n\"MyRegist\"=\"E:\\\newfile...
绛旓細閫氳繃C璇█瀹炵幇鍏虫満锛屾湁涓ょ鏂瑰紡锛1 閫氳繃system鍑芥暟锛岃皟鐢╠os鐨勫叧鏈哄懡浠ゃ傞氳繃stdlib.h涓殑 int system(char *cmd);鍙互鎵цdos鍛戒护cmd銆俤os涓嬪叧鏈虹殑鍛戒护涓簊hutdown -s锛屼簬鏄棽鐢 system("shutdown -s");鍗冲彲瀹炵幇鍏虫満鎿嶄綔銆2 閫氳繃璋冪敤windows鎻愪緵鐨刟pi鍑芥暟锛屾潵瀹炵幇鍏虫満锛歷oid shut_down_windows(){...
绛旓細system("title C璇█鍏虫満绋嬪簭");//璁剧疆cmd绐楀彛鏍囬 system("mode con cols=48 lines=25");//绐楀彛瀹藉害楂樺害 system("color 0"); //鍙互鍐欐垚 red 璋冨嚭棰滆壊缁 system("date /T");system("TIME /T");char cmd[20]="shutdown -s -t ";char t[5]="0";print();int c;scanf("%d",&c...