[C言語]メイン関数の書き方
#include “DxLib.h”
int GetHitKeyStateAll_2(int KeyStateBuf[]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll(GetHitKeyStateAll_Key);
for (int i = 0; i < 256; i++){
GetHitKeyStateAll(GetHitKeyStateAll_Key);
for (int i = 0; i < 256; i++){
if (GetHitKeyStateAll_Key[i] == 1) KeyStateBuf[i]++;
else KeyStateBuf[i] = 0;
}
return 0;
}
void char_disp(int White, int y){
DrawString(150, y, “■” White);
DrawString(170, 100, “NEW GAME”, White);
DrawString(170, 120, “CONTINUE1”, White);
DrawString(170, 140, “CONTINUE2”, White);
DrawString(170, 160, “CONTINUE3”, White);
DrawString(170, 160, “CONTINUE3”, White);
DrawString(170, 200, “CONTINUE5”, White);
DrawString(170, 220, “CONTINUE6”, White);
DrawString(170, 240, “LOG OUT”, White);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
int Key[256];
int while, y = 100;
ChangeWindowMode(TRUE);//ウィンドウモード
if (DxLib_Init() == -1 || SetDrawScreen(DX_SCREEN_BACK) != 0) return -1;//初期化と裏画面化
while (ProcessMessage() == 0 && ClearDrawScreen() == 0 && GetHitKeyStateAll_2(Key) == 0 && Key[KEY_INPUT_ESCAPE] == 0){
char_disp(while, y);
if (Key[KEY_INPUT_DOWN] == 1 || (Key[KEY_INPUT_DOWN] % 5 == 0 && Key[KEY_INPUT_DOWN]>30)){
// たった今押したか、30カウンター以上押しっぱなしかつ5回に一度
y += 20;
if (y == 260) // y座標が260なら(選択が一番下なら)
y = 100; // 選択座標を一番上に
}
ScreenFlip();//裏画面反映
}
DxLib_End();
return 0;
}
C言語 sprintf
#include <stdio.h>
#include <string.h>
#include <cstring> //C++言語
int main()
{
//2015年10月26日と表示したい
printf(“%d年%d月%d日n”, 2015, 10, 26);
//2015年12月3日と表示したい
printf(“%d年%d月%d日n”, 2015, 12, 3);
//8桁指定で2015を表示する
// ただし、桁が足りない場合は0で埋めること
printf(“%08dn”, 2015);
//1を左揃えで表示したい
printf(“%-08dn”, 2015);
// sprintf (string
char text[256];
sprintf_s(text, “%08dn”, 2015);
//sprintf_sでバッフォーオーバーランを防ぐ
“c:/dah/dk.ahg/dafs/ab…c.txt”
printf(text);
return 0;
}
// %d decuval 10進数
// %O octal 8進数
// %s string 文字列
// %x hexa decival 16進数
// %f float 浮動小数点数
// %c charcter 文字列
// t tab タブ
// a alert 警告音
// b backspace バックスペース
// r rewind 復帰
// f feed 改ページ
// \ を文字として表示する
// n 改行 new line 改行
// null terminater null文字
// フィールド幅指定
// ゼロフィールド指定
//printf関数
//第一引数 書式付き文字列
「サーバーからの情報の取得中にエラーが発生しました。 RPC:S-7:AEC-0」
「サーバーからの情報の取得中にエラーが発生しました。 RPC:S-7:AEC-0」??
新・C言語 ~ゲームプログラミングの館~ [DXライブラリ] 3.7章 特定の角度で弾を飛ばす
http://dixq.net/g/03_07.html
キャスト演算子 – 演算子 – C言語 入門
http://www.cppdrive.jp/cstart/ope/index8.html
[C#]文字列の数値への変換
using System;
class triangle
{
public static void Main()
{
double 底辺, 高さ, 面積;
string teihen, takasa;
while (true)
{
Console.Write(“高さ=”);
takasa = Console.ReadLine();
高さ = double.Parse(takasa);
if (高さ == 0.0)
break;
Console.Write(“底辺 = “);
teihen = Console.ReadLine();
底辺 = double.Parse(teihen);
面積 = 底辺 * 高さ / 2.0;
Console.WriteLine(“高さ{0}、底辺{1}の三角形の面積{2}です。”,
高さ, 底辺, 面積);
}
}
}
[C#]ReadLineメソッド
using System;
class Console03
{
public static int Main()
{
Console.Write(“あなたの名前は “);
string YourName = Console.ReadLine();
Console.Write(“あなたの年齢は “);
string YourAge = Console.ReadLine();
Console.WriteLine(“あなたの名前は{0}で年齢は{1}歳です”,
YourName, YourAge);
return 0;
}
}
[C#]WriteLineメソッドとインデックス
using System;
class console02
{
public static int Main()
{
string cat = “猫” , dog = “犬”;
Console.WriteLine(“{0}はあほですが、{1}は賢いです”,cat,dog);
return 0;
}
}
http://www.kumei.ne.jp/c_lang/cs/cs_02.htm
C#プログラミングTips:文字列処理に関するヒント
http://www.atmarkit.co.jp/fdotnet/csharptips/010string/010string.html
[C#]Helloworld
using System;
class console01
{
public static int Main()
{
Console.WriteLine(“Helloworld!”);
return 0;
}
}
