FRP是更加有效率地处理事件流,而无需显式去管理状态。
具体来说,FRP包括两个核心观点:
1.事件流,离散事件序列
2.属性properties, 代表模型连续的值。
一系列事件是导致属性值发生变化的原因。FRP非常类似于GOF的观察者模式。
#include <stdio.h>#include <ctype.h>
#include <stdlib.h>
int main(void)
{
float *data = NULL
char buf[32]
FILE *fp = NULL
int i = 0
if((fp = fopen("test.txt", "r")) == NULL)
{
printf("open file error!\n")
return -1
}
data = (float*)malloc(sizeof(float) * 120000)//分配内存存储数据
if(data == NULL)
{
printf("momery error!\n")
return -1
}
while(fgets(buf, 30, fp))
{
*(data + i) = atof(buf)
printf("%f\n", *(data + i))
i ++
}//data就是你要的数组
free(data) //释放内存
fclose(fp)
return 0
}