① 用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 != '