C
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- takezoh
- まろ
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- @tyottyoworks
- ___shanon
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
33
1
2
3
4
typedef int error_t;5
6
typedef struct vector_s7
{8
long *values;9
long dim;10
} vector_t;11
12
typedef struct vec_array_s13
{14
vector_t **vectors;15
long length;16
} vec_array_t;17
18
error_t vec_array_store(vec_array_t *array, vector_t *vec)19
{20
array->length = array->length + 1;21
(*array).vectors = realloc((*array).vectors, (*array).length *(sizeof(struct vector_s)));22
array->vectors[array->length-1] = vec;23
}24
25
int main(void) {26
vector_t hoge;27
vec_array_t a = {0, 0};28
vec_array_store(&a, &hoge);29
printf("%ld\n", a.length);30
printf("%p %p\n", (void*)&hoge, (void*)a.vectors[0]);31
return 0;32
}33
$ gcc prog.c -Wall -Wextra -std=gnu11
Start
prog.c: In function 'vec_array_store':
prog.c:23:1: warning: control reaches end of non-void function [-Wreturn-type]
23 | }
| ^
1 0x7ffdd189e720 0x7ffdd189e720
0
Finish