用c語言對話
❶ 怎麼用c語言編寫對話的形式急啊!!!!謝謝啦!!1
用 if 判斷條件
#include <stdio.h>
void main()
{
int a;
printf("1+1=?");
scanf("%d",&a);
if(a==2)//當用戶輸入的數值是2是就執行if下以行,否則的話就執行else後面的語句
printf("Very Good\n");
else
printf("ERROR\n");//error是錯誤的意思
}
要按你的意思的話,就要用if判斷語句,
當怎麼樣時....就怎麼樣.... 否則就怎麼樣...
❷ 用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 != '