📄 getsend.c
字号:
#include <stdlib.h>
#include <stdio.h>
/* GETSEND.C - getinput(), sendout(), and flush() functions for
PC based simulation using ASCII text disk I/O.
*/
/* getinput - get one sample from disk to simulate realtime input */
float getinput()
{
static FILE *fp = NULL;
float x;
/* open input file if not done in previous calls */
if(!fp) {
char s[80];
printf("\nEnter input file name ? ");
gets(s);
fp = fopen(s,"r");
if(!fp) {
printf("\nError opening input file in GETINPUT\n");
exit(1);
}
}
/* read data until end of file */
if(fscanf(fp,"%f",&x) != 1) exit(1);
return(x);
}
/* sendout - send sample to disk to simulate realtime output */
void sendout(float x)
{
static FILE *fp = NULL;
/* open output file if not done in previous calls */
if(!fp) {
char s[80];
printf("\nEnter output file name ? ");
gets(s);
fp = fopen(s,"w");
if(!fp) {
printf("\nError opening output file in SENDOUT\n");
exit(1);
}
}
/* write the sample and check for errors */
if(fprintf(fp,"%f\n",x) < 1) {
printf("\nError writing output file in SENDOUT\n");
exit(1);
}
}
/* dummy routine for flush */
void flush()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -