① c语言窗口程序,带可输入的文本框
#include<stdio.h>
#include<windows.h>
intmain()
{
charstr[99];
gets(str);
MessageBox(0,str,"对话框",MB_OK);
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 != '