2018-06-08から1日間の記事一覧

Python配列のループ処理色々

シンプルなのはこれ list1 = ['item1', 'item2', 'item3'] for item in list1: print(item)インデックスもほしいならenumerate()使う list1 = ['item1', 'item2', 'item3'] for index, item in enumerate(list1): print("インデックス:" + str(index) + ", …

ファイルサイズの計算に fseek() および ftell() を使用しない

C

fseek() からのftell()は推奨されないそうです。fstatを使うといいよ。 #include <io.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <share.h> FILE *fp; long file_size; char *buffer; struct stat stbuf; int fd; fd = open("foo.bin", O_RDONLY); if (fd == -1) { /* エラ</share.h></sys/stat.h></sys/types.h></fcntl.h></io.h>…