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

📄 fileconv.cpp

📁 关于TPM的一些应用
💻 CPP
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc,char *argv[])
{
	int idx = 0,si;
	char c, val[3], sOut[100];
	FILE *pInFile,*pOutFile;

	if(argc != 2)
	{
		printf("Wrong number of args %d\n",argc-1);
		return -1;
	}
	pInFile = fopen(argv[1],"rb");
	strcpy(sOut,argv[1]);
	strcat(sOut,".txt");
	pOutFile = fopen(sOut,"w");
	if (pInFile == NULL || pOutFile == NULL)
	{
		printf("Cannot open file\n");
		return -1;
	}
	
	fputc('{',pOutFile);
	c = fgetc(pInFile);
	while(1)
	{
      itoa((unsigned char)c,val,10);
	  for(si=0;si<strlen(val);si++)
		fputc(val[si],pOutFile);
	  c = fgetc(pInFile);
	  //since it's a binary file all values including EOF are valid
	  if(c == EOF && feof(pInFile)) break;
	  fputc(',',pOutFile);
	  idx++;
    }
	fputc('}',pOutFile);
	fclose(pInFile);
	fclose(pOutFile);
	return 0;
}

⌨️ 快捷键说明

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