書式付き出力wsprintf

サンプルプログラム

/* 書式付き出力 wsprintf(gui03.c) 2004/02/21(Sat) */ #include<windows.h> int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { CHAR chStr[128]; wsprintf(chStr, "インスタンドハンドル:%09d", hInstance); MessageBox(NULL , chStr , TEXT("インスタンスハンドル確認") , MB_OK); return 0; }

実行結果

文字列コピーlstrcpy

サンプルプログラム

/* 文字列コピー lstrcpy(gui03_2.c) 2004/02/21(Sat) */ #include<windows.h> int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { TCHAR *tchstr1 = TEXT("文字列のコピー"); TCHAR tchstr2[32]; lstrcpy(tchstr2, tchstr1); MessageBox(NULL , tchstr2 , tchstr1 , MB_OK); return 0; }

実行結果

指定文字数コピー lstrcpyn

サンプルプログラム

/* 指定文字数コピー lstrcpyn(gui03_3.c) 2004/02/21(Sat) */ #include<windows.h> int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { TCHAR *tchstr1 = TEXT("指定文字数コピー"); TCHAR tchstr2[32]; lstrcpyn(tchstr2, tchstr1, 11); MessageBox(NULL , tchstr2 , tchstr1 , MB_OK); return 0; }

実行結果

文字数取得 lstrlen

サンプルプログラム

/* 文字数取得 lstrlen(gui03_4.c) 2004/02/21(Sat) */ #include<windows.h> int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { TCHAR *tchstr1 = TEXT("指定文字数コピー"); TCHAR tchstr2[64]; int iwc; iwc=lstrlen(tchstr1); wsprintf(tchstr2, "文字数:%03d", iwc); MessageBox(NULL , tchstr2 , tchstr1 , MB_OK); return 0; }

実行結果

文字列結合 lstrcat

サンプルプログラム

/* 文字列結合 lstrcat(gui03_5.c) 2004/02/21(Sat) */ #include<windows.h> int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { TCHAR tchstr1[128] = TEXT("ROBO-ONE\n"); TCHAR *tchstr2 = TEXT("がんばろう!"); lstrcat(tchstr1, tchstr2); MessageBox(NULL , tchstr1 , tchstr2 , MB_OK); return 0; }

実行結果

BorlandC++Compilerの目次へ

トップページへ

SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送