static
記憶クラス
static:ブロックの有効範囲内:前の値を保存
https://www.sejuku.net/blog/25517
https://daeudaeu.com/c-static-local/
https://chat.openai.com/c/c540ceb0-a3a3-4048-832a-4d5ac280e3e0
別の関数で呼び出した場合
code:c
#include
<stdio.h>
void test(){
static int a = 0;
a++;
printf("a=%d\n",a);
}
void func1(){
test();
}
void func2(){
test();
}
int main(void){
// Your code here!
func1();
func2();
}
https://paiza.io/projects/ZWkOMntBL97QrKvblqXCvQ
他のファイルで使用した場合
https://paiza.io/projects/LCW6cySNUUluq1uTuRO-Ww?language=c