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

📄 16to8.c

📁 将16位格式的数字串转化为8位格式的数字串; 输入16位数字的文件
💻 C
字号:
#include <stdio.h>
#include <stdlib.h>




main()
{
	FILE *in , *out;

	int a,b;

	char ch,*infile,*outfile;

/*	printf("Please Enter the Inputfile Name:\n");
	scanf("%s",infile);
	
	printf("Please Enter the Outputfile Name:\n");
	scanf("%s",outfile);
*/
  
 
    infile = "1.tab";
	outfile = "o.tab";

    if ((in=fopen(infile,"r"))==NULL)
	{
	    printf("Cannot open Input file!\n");
		exit(0);
	}

    if ((out=fopen(outfile,"w"))==NULL)
	{
	    printf("Cannot open Output file!\n");
		exit(0);
	}


	//while (ch!=EOF)
	while(1)
	{
		//ch=fgetc(in);
		//if (ch==' ')	continue;
		//if (ch=='\n') continue;

	//	if(fscanf(in,"%x,",&a) <= 0) break;//      if input is hex
       if(fscanf(in,"%d,",&a) <= 0) break;//if input is decimalist
        if (a<0)
			a=65536+a;

		b=a/256;
		a=a%256;
		if((a <= 0xf)&&(a>=0))
			fprintf(out,"0%X\n",a);
		else
			fprintf(out,"%X\n",a);
		if((b <= 0xf)&&(b>=0))
			fprintf(out,"0%X\n",b);
		else
			fprintf(out,"%X\n",b);

		//		printf("%d\n",a);
	}
//	getchar();

}

⌨️ 快捷键说明

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