UNIX リダイレクション

date
dotinstall:~ $ echo ‘cal’ > commands.txt
dotinstall:~ $ cat commands.txt
cal
dotinstall:~ $ echo ‘date’ >> commands.txt
dotinstall:~ $ cat commands.txt
cal
date
dotinstall:~ $ /bin/ash < commands.txt December 2022 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Tue Dec 27 20:04:43 JST 2022 dotinstall:~ $ /bin/ash < commands.txt > results.txt
dotinstall:~ $ cat results.txt
December 2022
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Tue Dec 27 20:05:01 JST 2022
dotinstall:~ $ rm ‘
>

C# 変数の型

using System;

class MyApp
{

static void Main()
{
// 変数: 再代入が可能
// 定数: 再代入が不可能
string s = “hello”;
char c = ‘a’;

int i = 100;

double d = 52342.34;
float f = 23.3f;

//論理
bool flag = true;

var x = 5;
var y = “world”;
}

}

WindowsAPI 終了処理

#include

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
switch (msg) {
case WM_DESTROY:
MessageBox(hwnd, TEXT(“魔王を倒した”),
TEXT(“勇者の攻撃”), MB_ICONINFORMATION);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wp, lp);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCndLine, int nCmdShow) {
HWND hwnd;
MSG msg;
WNDCLASS winc;

winc.style = CS_HREDRAW | CS_VREDRAW;
winc.lpfnWndProc = WndProc;
winc.cbClsExtra = winc.cbWndExtra = 0;
winc.hInstance = hInstance;
winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL, IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
winc.lpszMenuName = NULL;
winc.lpszClassName = TEXT(“勇者”);

if (!RegisterClass(&winc))return 0;

hwnd = CreateWindow(
TEXT(“勇者”), TEXT(“勇者の攻撃!”),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 200, 200, NULL, NULL,
hInstance, NULL
);

if (hwnd == NULL)return 0;

while (GetMessage(&msg, NULL, 0, 0))DispatchMessage(&msg);
return msg.wParam;
}