//从123.txt读数据,将读到的数据输入456.txt中
#include
#include
int main(void)
{
int i, j;
double Q[5][4];
FILE *fp;
if (NULL == (fp = fopen("123.txt", "r")))
{
printf("file not open!\n");
exit(0);
}
for (i=0; i<5; i++)
{
for (j=0; j<4; j++)
{
fscanf(fp, "%lf", &Q[i][j]);
}
}
fclose(fp);
if (NULL == (fp = fopen("456.txt", "w")))
{
printf("file not open!\n");
exit(0);
}
for (i=0; i<5; i++)
{
for (j=0; j<4; j++)
{
fprintf(fp, "%lf\n", Q[i][j]);
}
}
fclose(fp);
return 0;
}
#include
#include
using namespace std;
int main()
{
double Q[5][4];
ifstream fin("a.txt");//a.txt读入de文件
ofstream fout("b.txt");//b.txt输出de文件
char ch[20];
for(int i=0;i<5;i++)
for(int j=0;j<4;j++)
{
fin>>ch;
fout<
cout<
}
fin.close();
fout.close();
return 0;
}
#include
int main() {
int i,j;
double Q[5][4];
FILE *InputFP,*OutFP;
InputFP = fopen("F:\\VC\\in.txt","rt");
for(i = 0;i < 5;i++) {
for(j = 0;j < 4;j++) {
fscanf(InputFP,"%lf",&Q[i][j]);
printf("%7.2lf\n",Q[i][j]);
}
}
printf("\n");
fclose(InputFP);
OutFP = fopen("F:\\VC\\out.txt","wt");
for(i = 0;i < 5;i++) {
for(j = 0;j < 4;j++) {
fprintf(OutFP,"%7.2lf",Q[i][j]);
}
}
fclose(OutFP);
return 0;
}