index写成二进制文件.txt
来自「一些解决线形方程组的并行计算的程序,希望对大家有一点帮助」· 文本 代码 · 共 54 行
TXT
54 行
#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 + =
减小字号Ctrl + -
显示快捷键?