/***************************************************************** * asc2int.c - C program that convert integer in ASCII format file * to .int for CCS simulations *****************************************************************/ #include #include #include 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 */ }