asc2int.c

来自「用dsp解压mp3程序的算法」· C语言 代码 · 共 41 行

C
41
字号
/*****************************************************************
*  asc2int.c - C program that convert integer in ASCII format file
*              to .int for CCS simulations
*****************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void main()
{

/*****************************************************************
*    Clear variables
*****************************************************************/
  
  float en  = 0.0;              /* e(n) from data file en.dat   */
  int eni = 0;                  /* ei(n) in integer format      */
  
/*****************************************************************
*    Declare file pointers
*****************************************************************/

  FILE *en_in;                  /* file pointer for input file  */
  FILE *en_out;                 /* file pointer for output file */
  
  en_in = fopen("en.dat","r");  /* open file for input e(n)     */
  en_out = fopen("en.int","w"); /* open file for output ei(n)   */
  
/*****************************************************************
*    Start of main program
*****************************************************************/
  while( (fscanf(en_in,"%f",&en)) != EOF)
  {                              /* read in e(n) from data file */
    eni = (int)(en + 0.5);       
    fprintf(en_out,"    .int  %d\n",eni); /* output ei(n)       */

  }
  fcloseall();                        /* close all opened files */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?