深い意味はない。 Hash_table.c #include<stdio.h> #include<stdlib.h> #include<string.h> #define Max_key_length 128 #define Form inttypedefstruct_Data{charkey[Max_key_length];/*用途によって変更*/Formval;}Data;typedefstruct_Map{Data*hash_table;unsignedsize;unsignedamount;}Map;intmake_hash...
#include<stdlib.h>voidfree(void*ptr); まず、free関数を利用する際にはstdlib.hをインクルードしておく必要があります。 また、free関数の戻り値の型はvoidです。つまり何も返却しません。 さらに、引数ptrの型はvoid *です。 要は引数する変数の型としては、int *でもchar *でも、さらには...
#include "interviewer.h" #include <stdio.h> #include <stdlib.h> #define LENGTH(array) (sizeof(array)/sizeof(array[0])) static Interviewer interviewer_infra_red_new() { printf("インフラレッドに質問機会など与えられません。\n"); exit(1); } static Interviewer get_interviewer_by_compu...
この関数はfeofがゼロを返すまで呼び出され、ファイルストリームがEOFに達していないことを意味します。関数getlineの戻り値を条件文で確認し、成功した場合にのみprintfを呼び出して読み込んだ行を出力することに注意してください。 #include<stdio.h>#include<stdlib.h>#include<sys/stat.h>const...
#include<stdio.h>#include<stdlib.h>staticintj=0;voidup(void){staticintk=0;j++;k++;printf(" up() called. k=%2d, j=%2d\n",k,j);}intmain(){inti;for(i=0;i<3;i++)up();exit(EXIT_SUCCESS);} 出力: up() called. k= 1, j= 1up() called. k= 2, j= 2up() called. k...
はじめに「C言語でトライ! デザインパターン」。間が空きましたが再開します。今回はFactory Methodパターン。Abstruc Factoryと似たように生成部分を抽象化する形ですが、生…
Subscriberプログラムでトピックに「#」を指定すると、「すべてのトピック」の意味になります。Subscriberのコーディングをした時にトピック関連処理のバグかどうかの切り分けに役立つことが、たまに、あります。 一つのプログラムでPublisher/Subscriberの両方を実装する場合 ...
#include<stdio.h>#include<stdlib.h>intmain(intargc,charconst*argv[]){typedefstruct{intn1;shorts1;char*p;charc1;charc2;}foo1;typedefstruct{char*p;intn1;shorts1;charc1;charc2;}foo2;typedefstruct{intn1;shorts1;char*p;charc1;charc2;}__attribute__((packed))foo3;printf("sizeof foo1 = ...
関数 execvp はスラッシュを含まないファイル名を受け取ることができ、環境変数 PATH で指定されたディレクトリでファイルが検索されることを意味します。 #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(void) { const char *args[] = {"vim"...
このときツールが自動でdpiheader.hをプロジェクト・ディレクトリに生成していました。 さらに、このdpiheader.hでは、#include "svdpi.h"と記述されており、ファイル名から 推察して、svdpi.hがDPI-Cとの関連付けを行っているように感じています。