2021-04-12から1日間の記事一覧

基本情報技術者試験 ファイルの内容を16進数で表示する

令和元年度秋期の基本情報技術者試験の午後問題の問9の「ファイルの内容を16進数で表示する」プログラムを実行しました。 #include <stdio.h> #include <stdlib.h> #define WIDTH 60 #define MASKCHR '.' void dump(char *filename, long from, long to) { FILE *infile; int c</stdlib.h></stdio.h>…

Pythonでアスキーコード0x20から0X7Eの文字をファイルに出力する

文字から文字コードを取得する >>> ord('a') 97 >>> ord('z') 122 >>> ord('A') 65 >>> ord('Z') 90 >>> ord('0') 48 >>> ord('9') 57 >>> ord(' ') 32 >>> ord('~') 126 16進数で表示するなら >>> hex(ord('a')) '0x61' >>> hex(ord(' ')) '0x20' >>> hex(o…