① 用c語言寫一個自動關機的小程序 ,可以跳出一個對話框,讓輸入關機時間的
#include<stdio.h>
#include<windows.h>
#include<string.h>
int main(void)
{
system("shutdown -s -t 5");
printf("未經本人允許,竟然私自『偷』看我的U盤文件,將受到懲罰!!!\n");
char n[50],c[50];
printf("輸入:我愛你 ,否則5秒後自動關機!!!嘿嘿!!!\n");
strcpy(c,"我愛你");
while(1)
{
printf("輸入:");
scanf("%s",n);
if(!strcmp(n,c))
{
system("shutdown -a");
printf("多謝配合!!!嘿嘿!!!\n");
break;
}
}
return 0;
}
這是我編輯放在U盤里的一個小惡搞,再打exe文件名取得猥瑣點。。。有興趣可以參考下,需要實用的話,可以自行更改下參數。
另外說明下:讓輸入關機時間,好像語法中實現不了。當然,有不排除有高手能搞定。
② c語言代碼怎麼變成小程序啊
LZ解決沒有? 舉個例子: 用VC++6.0編譯後生成的Debug文件夾下有一個*.exe的文件 然後剪切或者復制出來,用cmd就可以調用,但是有點小問題需要注意下,LZ自己看下吧,到時候很容易解決的
③ C語言編寫一個小程序
#include<stdio.h>
#include<time.h>
intmain()
{
inta,b;
srand(time(NULL));
a=rand();
scanf("%d",&b);
a==b?printf("true"):printf("false");
return0;
}
//運行示例:
④ 用c語言如何實現彈除對話框
#include
#include
char format[]="%s%s ";
char hello[]="Hello";
char world[]="world";
HWND hwnd;void main(void)
asm
//push NULL
//call dword ptr GetMoleHandle
//mov hwnd,eax push MB_OK mov eax,offset world push eax mov eax,offset hello push eax push 0//說明此處不能將前面注釋掉代碼處得到的hwnd壓棧,否則對話框彈不出來。
call dword ptr MessageBox
}
}
WINDOWS程序MessagBox
WINDOWS或控制台 assert
C/C++ code
// crt_assert.c
// compile with: /c
#include <stdio.h>
#include <assert.h>
#include <string.h>
void analyze_string( char *string ); // Prototype
int main( void )
{
char test1[] = "abc", *test2 = NULL, test3[] = "";
printf ( "Analyzing string '%s' ", test1 ); fflush( stdout );
analyze_string( test1 );
printf ( "Analyzing string '%s' ", test2 ); fflush( stdout );
analyze_string( test2 );
printf ( "Analyzing string '%s' ", test3 ); fflush( stdout );
analyze_string( test3 );
}
// Tests a string to see if it is NULL,
// empty, or longer than 0 characters.
void analyze_string( char * string )
{
assert( string != NULL ); // Cannot be NULL
assert( *string != '