- C言語なら俺に聞け
301 :デフォルトの名無しさん[]:2015/02/22(日) 15:18:52.26 ID:YCoQmSjP - 構造体struct foo
struct fooとかくのがめんどくさい場合 typedef struct foo foo; struct foo { int number; char [BUFFER_SIZE]; }; foo a; foo *p = &a; C++のclassは、privateであって、途中でpublicを指定するが、 C++のstructは、なにもしなかったらpublic
| - C言語なら俺に聞け
304 :デフォルトの名無しさん[]:2015/02/22(日) 15:24:55.23 ID:YCoQmSjP - #define BUFFER_SIZE 80
#include <stdio.h> #include <string.h> typedef struct foo foo; struct foo { int number; char c[BUFFER_SIZE]; }; int main(void) { foo a, b; foo *p = &a; foo *q = &b; a.number = 2; strcpy(a.c, "two"); b = a; printf("%d: %s\n", q->number, q->c); return 0; }
| - C言語なら俺に聞け
306 :デフォルトの名無しさん[]:2015/02/22(日) 15:30:52.09 ID:YCoQmSjP - #include <stdio.h>
int main(void) { int a = 2; { int a = 13; printf("a = %d inside the block\n", a); } printf("a = %d outside the block\n", a); return 0; }
|
|