⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ngn格式转换小程序

📁 ngn格式转换程序proc*c
💻
字号:
#include <stdio.h>#include <string.h>#include <stdlib.h>#include <sqlda.h>#include <sqlcpr.h>#include <dirent.h>#include <unistd.h>#include <fcntl.h>#include <math.h>#include <ctype.h>#include <float.h>#define COUNT 10000000long teleno_arry[1000000][5];/*声明变量*/long latn_acc_nbr;long latn_cj_meter1,latn_cj_meter2,latn_cj_meter3,latn_cj_meter4;/*记录总电话数*/long i_var=0;/*查找函数*/int look_teleno(long teleno_temp,long i_var_temp){for(long j=0;j<=i_var_temp;j++)   if(teleno_arry[j][0]==teleno_temp)       {       return j;      }   return -1;} int main(int argc,char** argv){long i_number=0;/*声明读目录的变量*/DIR *dp;struct dirent *dir;char dir_file[49]="/home/bill1/latn/lixl/ngn_format_tr/data_source/";/*声明读文件的变量*/FILE *fp_i,*fp_o;char *location_ptr;long location,number_read;char file_text[COUNT];char file_name[100];/*声明解析文件变量*/char char_teleno[9],char_cj_meter1[9],char_cj_meter2[9],char_cj_meter3[9],char_cj_meter4[9];/*设置变量初始值*/printf("argv:%d\n",argc);if(argc!=3) {printf("Usage:backup 标准输出文件名 数据源路径.\n"); return 1;}for(long a=0;a<1000000;a++)    for( long b=0;b<5;b++)          teleno_arry[a][b]=0;/*打开目录*/dp=opendir(dir_file);/*打开日志文件*/if((fp_o=fopen("/home/bill1/latn/lixl/ngn_format_tr/log_ngn_file.log","w"))==NULL)		{                 printf("cannot open file:%s\n",file_name);	         return -1;		}while((dir=readdir(dp))!=NULL){		if(strcmp(dir->d_name,".")!=0&&strcmp(dir->d_name,"..")!=0)     {	/*取文件绝对路径*/	printf("test1.%d\n",strlen(dir_file));        for(long aa=0;aa<strlen(dir_file);aa++)        	file_name[aa]=dir_file[aa];        //strcpy(file_name,dir_file);        printf("test2.%s\n",file_name);        file_name[48]='\0';        printf("test3.\n");        //strcat(file_name,dir->d_name);        for(long g=0;g<strlen(dir->d_name);g++)        	file_name[48+g]=dir->d_name[g];        file_name[48+g]='\0';        printf("the file_name is:%s\n",file_name);        /*打开文件*/	if((fp_i=fopen(file_name,"r"))==NULL)			{			 printf("cannot open file:%s\n",file_name);			 return -1;			}	fread(file_text,COUNT,1,fp_i);	fseek(fp_i,0,SEEK_END);	number_read=ftell(fp_i);	location_ptr=file_text;	location=0;	printf("strlen:number_read%ld%ld\n",strlen(file_text),number_read);	/*解析文件*/	while(location<=number_read-122) 	{ 		/*teleno*/ 		strncpy(char_teleno,location_ptr,8); 		printf("char_teleno:%s\n",char_teleno); 		location_ptr=location_ptr+11; 		/*meter1*/ 		strncpy(char_cj_meter1,location_ptr,8); 		location_ptr=location_ptr+11; 		/*meter2*/ 		strncpy(char_cj_meter2,location_ptr,8); 		location_ptr=location_ptr+11; 		/*meter3*/ 		strncpy(char_cj_meter3,location_ptr,8); 		location_ptr=location_ptr+11; 		/*meter4*/ 		strncpy(char_cj_meter4,location_ptr,8); 		location_ptr=location_ptr+78; 		latn_acc_nbr=atol(char_teleno); 		latn_cj_meter1=atol(char_cj_meter1); 		latn_cj_meter2=atol(char_cj_meter2); 		latn_cj_meter3=atol(char_cj_meter3); 		latn_cj_meter4=atol(char_cj_meter4); 		location=location+122;		/*累积数据*/        	//if (latn_cj_meter1!=0||latn_cj_meter2!=0||latn_cj_meter3!=0||latn_cj_meter4!=0)        	if(1)			{				i_number=look_teleno(latn_acc_nbr,i_var);						//printf("i_number:%d,latn_acc_nbr:%8d%8d%8d%8d%8d\n",i_number,latn_acc_nbr,				//latn_cj_meter1,latn_cj_meter2,latn_cj_meter3,latn_cj_meter4);				if(i_number>=0)  				{				teleno_arry[i_number][1]=teleno_arry[i_number][1]+latn_cj_meter1;				teleno_arry[i_number][2]=teleno_arry[i_number][2]+latn_cj_meter2;				teleno_arry[i_number][3]=teleno_arry[i_number][3]+latn_cj_meter3;				teleno_arry[i_number][4]=teleno_arry[i_number][4]+latn_cj_meter4; 				}				else				{				/*增加一个电话号码*/				teleno_arry[i_var][0]=latn_acc_nbr;				teleno_arry[i_var][1]=teleno_arry[i_var][1]+latn_cj_meter1;				teleno_arry[i_var][2]=teleno_arry[i_var][2]+latn_cj_meter2;				teleno_arry[i_var][3]=teleno_arry[i_var][3]+latn_cj_meter3;				teleno_arry[i_var][4]=teleno_arry[i_var][4]+latn_cj_meter4; 				//fprintf(fp_o,"teleno:%8d%8d%8d%8d%8d\n",teleno_arry[i_var][0],teleno_arry[i_var][1],teleno_arry[i_var][2],teleno_arry[i_var][3],teleno_arry[i_var][4]);				/*下一个电话号码的下标*/				i_var=i_var+1;								}			}	 }      fclose(fp_i);      }    } for(long j_var=0;j_var<i_var;j_var++)  {  fprintf(fp_o,"%-8d%8d%8d%8d%8dFJQ\n",teleno_arry[j_var][0],teleno_arry[j_var][1],teleno_arry[j_var][2],teleno_arry[j_var][3],teleno_arry[j_var][4]);  }  fclose(fp_o);  return 1;  }

⌨️ 快捷键说明

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