2010-07-01から1ヶ月間の記事一覧

『明解C言語 入門編』in multi language

『明解C言語 入門編』in multi language 柴田望洋『明解C言語 入門編』を勉強してまいります。 1. まずは慣れよう 000.整数値 15 と 37 の和を表示する 001.整数値 15 から 37 を引いた値を表示する 002.整数値 15 と 37 の和を親切に表示する 003.2つの変…

ポインタのソート

明解C言語 入門編 > 12. 構造体 > ポインタのソート C #include <stdio.h> #include <string.h> #include <alloc.h>#define NINSU 5typedef struct { char name[20]; int height; float weight; } gstudent;typedef int (*compare)(gstudent*, gstudent*);int compare_height(gstudent* </alloc.h></string.h></stdio.h>…

構造体の動的配列 (realloc)

明解C言語 入門編 > 12. 構造体 > 構造体の動的配列 (realloc) C #include <stdio.h> #include <string.h> #include <alloc.h>#define NINSU 5typedef struct { char name[20]; int height; float weight; } gstudent;typedef int (*compare)(gstudent*, gstudent*);int compare_height(</alloc.h></string.h></stdio.h>…

構造体の動的配列 (malloc)

明解C言語 入門編 > 12. 構造体 > 構造体の動的配列 (malloc) C #include <stdio.h> #include <string.h> #include <alloc.h>#define NINSU 5typedef struct { char name[20]; int height; float weight; } gstudent;typedef int (*compare)(gstudent*, gstudent*);int compare_height(g</alloc.h></string.h></stdio.h>…

5人の学生を 身長・体重で ソート (関数ポインタ)

明解C言語 入門編 > 12. 構造体 > 5人の学生を 身長・体重で ソート (関数ポインタ) C #include <stdio.h> #include <string.h>#define NINSU 5typedef struct { char name[20]; int height; float weight; } gstudent;typedef int (*compare)(gstudent*, gstudent*);int comp</string.h></stdio.h>…

5人の学生を 身長で ソート (構造体)

明解C言語 入門編 > 12. 構造体 > 5人の学生を 身長で ソート (構造体) C #include <stdio.h> #include <string.h>#define NINSU 5typedef struct { char name[20]; int height; float weight; } gstudent;void swap(gstudent* x, gstudent* y) { gstudent tmp = *x; *x = *y;</string.h></stdio.h>…

構造体を返す関数

明解C言語 入門編 > 12. 構造体 > 構造体を返す関数 C #include <stdio.h> #include <string.h>typedef struct { char name[20]; int height; float weight; } gstudent;gstudent hiroko(char name[], int height, float weight) { gstudent tmp; strcpy(tmp.name, name); tmp.</string.h></stdio.h>…

構造体と typedef

C

明解C言語 入門編 > 12. 構造体 > 構造体と typedef C #include <stdio.h> #include <string.h>typedef struct { char name[20]; int height; float weight; } gstudent;void hiroko(gstudent* std) { std->height = 180; std->weight = 80; }int main(int argc, char* argv[])</string.h></stdio.h>…

-> 演算子

C

明解C言語 入門編 > 12. 構造体 > -> 演算子 C #include <stdio.h> #include <string.h>struct gstudent { char name[20]; int height; float weight; };void hiroko(struct gstudent* std) { std->height = 180; std->weight = 80; }int main(int argc, char* argv[]) { struc</string.h></stdio.h>…

構造体の受け渡し

明解C言語 入門編 > 12. 構造体 > 構造体の受け渡し C #include <stdio.h> #include <string.h>struct gstudent { char name[20]; int height; float weight; };void hiroko(struct gstudent* std) { (*std).height = 180; (*std).weight = 80; }int main(int argc, char* argv</string.h></stdio.h>…

構造体のメンバの初期化

明解C言語 入門編 > 12. 構造体 > 構造体のメンバの初期化 C #include <stdio.h> #include <string.h>struct gstudent { char name[20]; int height; float weight; };int main(int argc, char* argv[]) { struct gstudent sanaka = {"Sanaka", 175, 60.5}; printf("氏名:%s\n</string.h></stdio.h>…