create a human readable output file with char arrays

The program must be able to work for an input file that contains following information:

# of temperature readings
timestamp
temperature
[# of temperature readings] [time stamp] [temperature]

input file example:
2
200707211245 F70.5
200708220812 C19.97

without using string objects how can I use char arrays to rearrange the data so when printed to the output it is in a human-readable string. (see below)

I also need to be able to convert Farenheit to Celcius, and then calculate the average temperature, and display it to the output.

output file example:

BIODATA Formatted Output
<blank space>
21.38 C --- recorded on 07/21/2007 at 1245
19.97 C --- recorded on 08/22/2007 at 0812
<blank space>
Average Temp --- 20.68 C


what I have so far is not much but here it is. There are some unused variables but that's because I was just messing around trying to figure it out.

#include <iostream>
#include <fstream>

using namespace std;

void OutputFormat(ofstream &fout);

int main()
{

int num_of_temp_readings = 0;

char time_stamp[256];

double temperature = 0,
avg_temp = 0;




ofstream fout;
fout.open("Filtered_biodata.dat");

if(!fout)
{
cout << endl << endl
<< "Program terminated!" << endl << endl
<< "Output failed to open." << endl;

}

ifstream fin;
fin.open("biodata.dat.txt");

if(!fin)
{
cout << endl << endl
<< "Program terminated!" << endl << endl
<< "input failed to open." << endl;
}





fin >> num_of_temp_readings;


for(int i = 0;i < num_of_temp_readings; i++)
{
fin.getline( time_stamp, 256);
cout << time_stamp << endl;

}



fout.close();
fin.close();

return 0;
}
I posted something similar a few days ago but I thought I should post again since my original post was very vague.
Why didn't you bother responding to the people that tried to help you there?
And use code tags when posting code.
Sorry about that I am new to site and don’t actually know how to use code tags. I saw it on another post so I will edit them in
It's now up to you to convert what's in the buffer each time to formatted output.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <fstream>

int main()
{
    int no_records = 0;
    
    char buffer[200];

    std::ifstream myfile ("bio_data_in.txt");
    if (myfile.is_open())
    {
        myfile >> no_records;
        
        for(int i = 0; i < no_records * 2; i++)
        {
            myfile >> buffer;
            std::cout << "Line: " << i/2 << " - " << buffer << '\n';
        }
        myfile.close();
    }
    else
        std::cout << "Unable to open file";
    
    return 0;
}
Topic archived. No new replies allowed.