#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(int argc, char* argv[])
{
#define COLUMNS 6
#define MAX_ROWS 100
FILE* fpRead = NULL, * fpWrite = NULL ;
double a[MAX_ROWS * COLUMNS];
int rows, count;
fpRead = fopen("data.txt", "r");
if (fpRead == NULL)
{
return 1;
}
count = 0;
while (1 == fscanf(fpRead, "%lf", &a[count]))
{
count++;
}
fclose(fpRead);
fpWrite = fopen("data_.txt", "w");
if (fpWrite == NULL)
{
return 1;
}
rows = count / COLUMNS;
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < COLUMNS; j++)
{
fprintf(fpWrite, "%lf ", a[i * COLUMNS + j]);
}
fprintf(fpWrite, "\n");
}
fclose(fpWrite);
return 0;
}