Cプログラミング
 Computer >> コンピューター >  >> プログラミング >> Cプログラミング

Cのダブルポインター(ポインターからポインター)


ポインタは、変数のアドレスを格納するために使用されます。したがって、ポインタへのポインタを定義するとき、最初のポインタは2番目のポインタのアドレスを格納するために使用されます。したがって、これはダブルポインタとして知られています。

アルゴリズム

Begin
   Declare v of the integer datatype.
      Initialize v = 76.
   Declare a pointer p1 of the integer datatype.
   Declare another double pointer p2 of the integer datatype.
   Initialize p1 as the pointer to variable v.
   Initialize p2 as the pointer to variable p1.
   Print “Value of v”.
      Print the value of variable v.
   Print “Value of v using single pointer”.
      Print the value of pointer p1.
   Print “Value of v using double pointer”.
      Print the value of double pointer p2.
End.

ダブルポインタを理解するための簡単なプログラム:

int main() {
   int v = 76;
   int *p1;
   int **p2;
   p1 = &v;
   p2 = &p1;
   printf("Value of v = %d\n", v);
   printf("Value of v using single pointer = %d\n", *p1 );
   printf("Value of v using double pointer = %d\n", **p2);
   return 0;
}

出力

Value of v = 76
Value of v using single pointer = 76
Value of v using double pointer = 76

  1. データ構造のダブルハッシュ

    このセクションでは、オープンアドレッシングスキームでのダブルハッシュ手法とは何かを説明します。通常のハッシュ関数h´(x):U→{0、1、。 。 。、m –1}。オープンアドレッシングスキームでは、実際のハッシュ関数h(x)は、スペースが空でないときに通常のハッシュ関数h’(x)を使用し、別のハッシュ関数を実行してスペースを挿入します。 $$ h_ {1}(x)=x \:mod \:m $$ $$ h_ {2}(x)=x \:mod \:m ^ {\ prime} $$ $$ h(x、i)=(h ^ {1}(x)+ ih ^ {2})\:mod \:m $$ iの値=0、1 、。

  2. Double DESとは何ですか?

    Data Encryption Standard(DES)は、64ビットのプレーンテキストと56ビットのキーを入力として作成し、64ビットの暗号文を出力として作成する対称キーブロック暗号です。 DES機能は、PボックスとSボックスで構成されています。 Pボックスはビットを転置し、Sボックスはビットを置き換えて暗号を作成します。 DESは、LUCIFERと呼ばれるFeistelブロック暗号の実装です。 16ラウンドのFeistel構造が必要であり、ラウンドごとに異なるキーを使用できます。 DES(Data Encryption Standard)を理解する主な理由は、DES(Data Encr