📄 index写成二进制文件.txt
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
int InputIndexFile(const char * pcInFile,const char* pcOutFile)
{
FILE *fp;//define the open file point
FILE *bp;//define the writer file point
char buffer[40]; //putinto every line
int i=0;
if((fp=fopen(pcInFile,"r"))==NULL)//open the index file
{
printf("can not open the index file.please check your file path!\n ");
exit(0);
}
if((bp=fopen(pcOutFile,"wb"))==NULL)//create a file
{
printf("can not open the file~!\n");
exit(0);
}
while(fgets(buffer,40,fp))
{
// fgets(buffer,30,lp);//get strings and put them into buffer
printf("%s",buffer);
fwrite(buffer,1,40,bp);//write a bin file
i=i+1;
}
fclose(fp);
printf("write successfully,%d Line\n",i);
fclose(bp);
return 0;
}
int main()
{
string InFile;
string OutFile;
cout<<"please input your file nane:"<<endl;
cin>>InFile;
cout<<"pease input your outfile name :"<<endl;
cin>>OutFile;
const char *pInFile=0;
const char *pOutFile=0;
pInFile=InFile.c_str();//string convert ti const char*
pOutFile=OutFile.c_str();
InputIndexFile(pInFile,pOutFile);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -