• 検索結果がありません。

郢晄亢縺ケ晢スウ郢ァソ鬩滓ヲ

N/A
N/A
Protected

Academic year: 2021

シェア "郢晄亢縺ケ晢スウ郢ァソ鬩滓ヲ"

Copied!
3
0
0

読み込み中.... (全文を見る)

全文

(1)

1

ポインタ配列

学習のポイント ポインタ配列の使用法について学びます。  Cではポインタ型の配列も使用できます。ポインタ配列はいくつかの文字列データを 扱うときによく使います。ポインタ配列は、 char *name[3]; などと宣言します。

これによりname[0]、name[1]、name[2]という3つのchar型へのポインタ配列が用意さ れます。

 ポインタ配列に文字列データを初期化するには、

static char *name[] = {"Candy", "Nancy", "Eluza"};

とします。これで次のように文字列を参照することができます。 ところで、ポインタ配列を用いて、文字列の各文字を参照するには、name[2][0]などとし ます。これで文字列”Elza”の第0番目の文字である’E’が参照できます。 「C言語」(河西朝雄著 ナツメ社)93頁 name[2] name[1] name[0] 0 1 2 3 4 5 E l u z a [0] N a n c y [0] C a n d y [0] ポインタ配列 メモリ 1

(2)

1.1

例題

19

ポインタ配列で示される文字列を表示しなさい。 /* 例題19 C言語94頁 ポインタ配列で示される文字列を表示しなさい。 reidai19.c */ #include <stdio.h> int main() {

static char *name[] = {"Eluza","Candy","Emy","Ann"};

int i; for(i = 0; i < 4; i++){ printf("%s\n ", name[i]); } return 0; } 2

(3)

1.2

練習問題

19

名前データの先頭文字が’E’のものだけを表示するブロググラムを作りなさい。 /* 練習問題19 C言語94頁 名前データの先頭文字が’E’のものだけを表示するブロググラムを作りなさい。 rensyu18.c */ #include <stdio.h> int main() {

static char *name[] = {"Eluza","Candy","Emy","Ann"};

int i; for(i = 0; i < 4; i++){ if(*name[i] == ’E’){ printf("%s\n ", name[i]); } } return 0; } 3

参照

関連したドキュメント

There is a bijection between left cosets of S n in the affine group and certain types of partitions (see Bjorner and Brenti (1996) and Eriksson and Eriksson (1998)).. In B-B,

(The Elliott-Halberstam conjecture does allow one to take B = 2 in (1.39), and therefore leads to small improve- ments in Huxley’s results, which for r ≥ 2 are weaker than the result

[r]

“Breuil-M´ezard conjecture and modularity lifting for potentially semistable deformations after

lines. Notice that Theorem 4 can be reformulated so as to give the mean harmonic stability of the configuration rather than that of the separate foliations. To this end it is

S., Oxford Advanced Learner's Dictionary of Current English, Oxford University Press, Oxford

At the end of the section, we will be in the position to present the main result of this work: a representation of the inverse of T under certain conditions on the H¨older

支払方法 支払日 ※② 緊急時連絡先等 ※③.