Thread: Help needed on Read and Write Text file

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    12

    Help needed on Read and Write Text file

    Here is my header file with all the declarations and definitions for the program.
    Code:
    #include <iostream> // cout
    #include <fstream>  // fstream, ifstream, ofstream
    #include <iomanip>  // formatted output
    
    
    using namespace std;
    
    
    const int FLIGHT_SIZE = 200;
    const int FLIGHT_NO_SIZE = 10;
    const int CITY_SIZE = 25;
    const int TIME_SIZE = 4;
    
    
    const char fileName[] = "flightInformation.txt";
    const char fileName2[] = "departureFlightInfoOut.txt";
    const char fileName3[] = "arrivalFlightInfoOut.txt";
    
    
    struct fDepartInfo {
        char dflightNo [FLIGHT_NO_SIZE]; // An alphanumeric code, not exceeding 10 characters, identifying a flight number.
        char originCity [CITY_SIZE]; // A character field, not exceeding 30 characters, identifying the origin city 
        char departTime [TIME_SIZE]; // A character field, not exceeding 4 characters, describing the departure time in 24 hours and minutes format.
        char terminalNo; // A single digit code indicating the terminal number.
        int gateNo; // An integer number indicating the gate number
        int checkInNo; // An integer number indicating the check-in counter
    };
    
    
    struct fArrivalInfo {
        char aflightNo [FLIGHT_NO_SIZE]; // An alphanumeric code, not exceeding 10 characters, identifying a flight number.
        char desCity [CITY_SIZE]; // A character field, not exceeding 30 characters, identifying the destination city.
        char arrivalTime [TIME_SIZE]; // A character field, not exceeding 4 characters, describing the arriving time in 24 hours and minutes format.
        char terminalNo; // A single digit code indicating the terminal number.
        int gateNo; // An integer number indicating the gate number
        int checkOutNo; // An integer number indicating the check-in counter
    };
    
    
    union fInfo {    
        fDepartInfo dFlight;
        fArrivalInfo aFlight;
    };
    
    
    struct Flight {
        char flightCode;
        fInfo fi;
    }; 
    
    
    int readFlightInfo (fstream&, Flight fInfo[]);
    void outputFlightInfo(fstream&, Flight fInfo[], int);
    This function below read and write to 2 text files (departureFlightInfoOut.txt, arrivalFlightInfoOut.txt)

    Code:
    #include "flightInfo.h"
    
    
    // get info from studentInfo text file and store in array 
    int readFlightInfo (fstream& afile, Flight fInfo[]) {
         char extraKey; // to store extra hypens (-) on date of birth 
         
         // Open flight info text file for reading    
         afile.open (fileName, ios::in); 
         if (!afile) // if not afile
         {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
         }  
        
         
         cout << "--------------------------------------------------------" << endl;
         cout << fileName << " opened for reading" << endl;
         
         int i = 0;    // counter for looping
         while (afile >> fInfo[i].flightCode)
         {
            if (fInfo[i].flightCode == 'D')
            {
                    afile >> fInfo[i].fi.dFlight.dflightNo;
                    afile >> fInfo[i].fi.dFlight.originCity;    
                    afile >> fInfo[i].fi.dFlight.departTime;                
    
    
                    afile >> fInfo[i].fi.dFlight.terminalNo;
                    afile >> fInfo[i].fi.dFlight.gateNo;
                    afile >> fInfo[i].fi.dFlight.checkInNo; 
            
            }  else if (fInfo[i].flightCode == 'A')    {
                    afile >> fInfo[i].fi.aFlight.aflightNo;
                    afile >> fInfo[i].fi.aFlight.desCity;
                    afile >> fInfo[i].fi.aFlight.arrivalTime;    
    
    
                    afile >> fInfo[i].fi.aFlight.terminalNo;
                    afile >> fInfo[i].fi.aFlight.gateNo;
            }
            else {
                    cout << "There is no valid Flight Code in the text file!" << endl;
            }
    
    
            ++i;
            
            afile.clear(); 
            afile.ignore(1000, '\n'); // to ignore until newline
        }
    
    
        afile.close();
    
    
        cout << fileName << " closed successfully" << endl;
        cout << "--------------------------------------------------------" << endl;
    
    
        return i;    // i = number of flight records read
    }
    
    
    // Using the stored values in UowStudents array to generate a student transcript text file
    void outputFlightInfo(fstream& afile, Flight fInfo[], int noOfRecords)
    {        
        fstream dfile;
        dfile.open(fileName2, ios::out);
        if (!dfile) // if not afile
        {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
        }  
        cout << "--------------------------------------------------------" << endl;
        cout << fileName2 << " created, containing arrival information." << endl;
        
        afile.open(fileName3, ios::out);
        if (!afile) // if not afile
        {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
        }  
                
        for (int k = 0; k < noOfRecords; k++)
        {
                if (fInfo[k].flightCode == 'D')
                {
                        dfile << "Departure " << fInfo[k].fi.dFlight.dflightNo << " "
                              << fInfo[k].fi.dFlight.originCity << " "
                              << fInfo[k].fi.dFlight.departTime << " "
                               << fInfo[k].fi.dFlight.terminalNo << " "
                              << fInfo[k].fi.dFlight.gateNo << " "
                              << fInfo[k].fi.dFlight.checkInNo << endl;
                }
                else if (fInfo[k].flightCode == 'A')
                {
                        afile << "Arrival " << fInfo[k].fi.aFlight.aflightNo << " "
                              << fInfo[k].fi.aFlight.desCity << " "
                              << fInfo[k].fi.aFlight.arrivalTime << " "
                              << fInfo[k].fi.aFlight.terminalNo << " "
                              << fInfo[k].fi.aFlight.gateNo << endl;
                }
        }
        
    
    
        dfile.close();
        afile.close();
        cout << fileName2 << " written sucessfully" << endl;
        cout << "--------------------------------------------------------" << endl;
        cout << fileName3 << " written sucessfully" << endl;
        cout << "--------------------------------------------------------" << endl;
    }
    Open and Read this text file
    Code:
    D    3K161    Darwin    2305    1    9    2
    A    3K162    Darwin    0855    1    19
    D    3K201    Jakarta    0745    1    8    2
    A    3K202    Jakarta    1210    1    22
    D    3K247    Surabaya    1140    1    7    2
    D    3K281    Medan    1040    1    7    2
    A    3K282    Medan    1420    1    23
    D    3K283    Medan    1510    1    7    2
    A    3K284    Medan    1915    1    23
    A    3K684    Kuala_Lumpur    0950    1    25
    A    6E53    Chennai    0450    2    10
    D    6E54    Chennai    0550    2    4    2
    A    AF254    Paris    1510    1    18
    D    AF259    Paris    0105    1    5    4
    D    AI347    Chennai    0915    2    4    3
    A    AK701    Kuala_Lumpur    0710    1    25
    A    AK703    Kuala_Lumpur    0820    1    25
    D    BA12    London    2320    1    2    1
    D    BA15    Sydney    2005    1    7    1
    D    BA16    London    2255    1    2    1
    A    BI421    Brunei    1120    2    11
    A    BI423    Brunei    2035    2    11
    A    BR225    Taipei    1205    1    26
    D    BR226    Taipei    1310    1    3    4
    A    CA969    Beijing    2145    1    24
    A    CA975    Beijing    0630    1    24
    A    CI751    Taipei    2050    1    26
    D    CI752    Taipei    1025    1    3    3
    A    CI752    Surabaya    0925    1    20
    A    CI753    Taipei    1305    1    26
    A    CZ3039    Guangzhou    1650    1    25
    D    CZ3040    Guangzhou    1750    1    2    2
    D    EK353    Dubai    1010    1    6    8
    D    EK349    Dubai    0030    1    6    8
    A    GA822    Jakarta    0900    3    3
    D    GA823    Jakarta    0725    3    11    3
    A    GA824    Jakarta    1035    3    3
    A    GA854    Surabaya    1050    3    10
    D    GA855    Surabaya    2030    3    9    3
    A    IT511    Taipei    1435    2    14
    A    JT104    Surabaya    1120    3    10
    A    JT150    Jakarta    1105    3    3
    A    JT152    Jakarta    0900    3    3
    D    JT153    Jakarta        0945    3    9    6
    A    KL836    Bali    0000    1    21
    D    KL836    Amsterdam    0130    1    4    7
    A    KE641    Seoul    0010        2    8
    D    KE642    Seoul    0130    2    6    4
    D    LH779    Frankfurt    2355    3    4    3
    D    MH602    Kuala_Lumpur    0640    2    2    1
    A    MH609    Kuala_Lumpur    0005    2    13
    A    MI233    Medan    1105    2    9
    D    MI234    Medan    0730    2    3    1
    A    MI237    Medan    2220    2    9
    D    MI238    Medan    1900    2    3    1
    A    MI319    Kuala_Lumpur    0830    2    13
    D    MI320    Kuala_Lumpur    0600    2    2    1
    A    MI321    Kuala_Lumpur    0955    2    13
    D    MI322    Kuala_Lumpur    0710    2    2    1
    D    MI436    Chennai    0700    2    4    1
    A    MH601    Kuala_Lumpur    0905    2    13
    D    MI801    Darwin    1015    2    5    1
    A    MI802    Darwin    1900    2    15
    D    MI803    Darwin    2000    2    5    1
    A    MI804    Darwin    0610    2    15
    D    NZ281    Auckland    0850    3    11    2
    A    NZ282    Auckland    0645    3    8
    D    QF6        Sydney    2350    1    9    5
    D    QF82    Sydney    1955    1    9    5
    A    QZ262    Jakarta    0955    1    22
    D    QZ263    Jakarta    1020    1    8    6
    D    SQ2        San_Francisco    1830    3    7    1
    D    SQ12    Los_Angeles    0920    3    7    1
    D    SQ16    San_Francisco    0925    3    7    1
    A    SQ181    Brunei    1405    3    14
    D    SQ211    Sydney    0940    3    12    1
    D    SQ231    Sydney    0045    3    12    1            
    D    SQ241    Sydney    0705    3    12    1    
    A    SQ278    Adelaide    1640    3    7
    D    SQ285    Auckland    2050    3    11    1
    A    SQ286    Auckland    1900    3    8
    D    SQ295    Christchurch    2145    3    10    1
    D    SQ297    Christchurch    1945    3    10    1
    A    SQ298    Christchurch    1740    3    6
    D    SQ306    London    0115    3    3    1
    D    SQ318    London    1250    3    3    1
    D    SQ324    Amsterdam    2355    3    6    1
    D    SQ326    Frankfurt    1355    3    4    1
    D    SQ336    Paris    0010    3    2    1
    D    SQ366    Rome    0110    3    8    1
    D    SQ378    Barcelona    0140    3    5    1
    D    SQ468    Colombo    2305    3    1    1
    A    SQ469    Colombo    0755    3    9
    D    SQ494    Dubai    1505    3    11    1
    D    SQ608    Seoul    0010    3    1    1
    D    SQ616    Osaka    1405    3    1    1
    D    SQ618    Osaka    0130    3    1    1
    A    SQ801    Beijing    0645    3    11
    A    SQ805    Beijing    1520    3    11
    A    SQ807    Beijing    2320    3    11
    D    SQ850    Guangzhou    0810    3    10    3
    A    SQ851    Guangzhou    1740    3    13
    A    SQ853    Guangzhou    0555    3    12
    D    SQ876    Taipei    0830    3    2    1
    A    SQ877    Taipei    1850    3    15
    D    SQ930    Surabaya    0750    3    9    1
    A    SQ931    Surabaya    1330    3    10
    D    SQ950    Jakarta    0645    3    10    1
    A    SQ951    Jakarta    0810    3    3
    A    SQ953    Jakarta    1100    3    3
    D    TZ2        Sydney    0145    2    10    8
    D    TR2260    Surabaya    1120    2    7    5
    D    TR2274    Jakarta    0810    2    7    5
    A    TR2275    Jakarta    1240    2    12
    D    TR2634    Chennai    0740    2    4    5
    D    TR2986    Guangzhou    0605    2    4    5
    A    TR2987    Guangzhou    1450    2    9
    D    TR2988    Guangzhou    2140    2    2    5
    D    TR2992    Taipei    0830    2    1    5
    A    TR2997    Taipei    0055    2    14
    A    UL302    Colombo    1350    3    9
    A    UL306    Colombo    0730    3    9
    D    UL307    Colombo    1000    3    1    4
    A    UL308    Colombo    1840    3    9
    D    UL309    Colombo    1950    3    1    4
    The program should read the text file above and output the file in this format below.

    I want to read the file and save in this format instead.
    Code:
    Departure 3K201 Jakarta 0745 1 8 2 
    Departure QF82 Sydney 1955 1 9 5 
    Departure 3K161 Darwin 2305 1 9 2 
    Departure QF6 Sydney 2350 1 9 5

    But as you can see there is problem with the code, it outputs the flight number and country are joined together.

    As well as the depart time and terminalNo.


    Code:
    Arrival 3K162Darwin Darwin 08551 1 19
    Arrival 3K202Jakarta Jakarta 12101 1 22
    Arrival 3K282Medan Medan 14201 1 23
    Arrival 3K284Medan Medan 19151 1 23
    Arrival 3K684Kuala_Lumpur Kuala_Lumpur 09501 1 25
    Arrival 6E53 Chennai 04502 2 10
    Arrival AF254Paris Paris 15101 1 18
    Arrival AK701Kuala_Lumpur Kuala_Lumpur 07101 1 25
    Arrival AK703Kuala_Lumpur Kuala_Lumpur 08201 1 25
    Arrival BI421Brunei Brunei 11202 2 11
    Arrival BI423Brunei Brunei 20352 2 11
    Arrival BR225Taipei Taipei 12051 1 26
    Arrival CA969Beijing Beijing 21451 1 24
    Arrival CA975Beijing Beijing 06301 1 24
    Arrival CI751Taipei Taipei 20501 1 26
    Arrival CI752Surabaya Surabaya 09251 1 20
    Arrival CI753Taipei Taipei 13051 1 26
    Arrival CZ303Guangzhou Guangzhou 16501 1 25
    Arrival GA822Jakarta Jakarta 09003 3 3
    Arrival GA824Jakarta Jakarta 10353 3 3
    Arrival GA854Surabaya Surabaya 10503 3 10
    Arrival IT511Taipei Taipei 14352 2 14
    Arrival JT104Surabaya Surabaya 11203 3 10
    Arrival JT150Jakarta Jakarta 11053 3 3
    Arrival JT152Jakarta Jakarta 09003 3 3
    Arrival KL836Bali Bali 00001 1 21
    Arrival KE641Seoul Seoul 00102 2 8
    Arrival MH609Kuala_Lumpur Kuala_Lumpur 00052 2 13
    Arrival MI233Medan Medan 11052 2 9
    Arrival MI237Medan Medan 22202 2 9
    Arrival MI319Kuala_Lumpur Kuala_Lumpur 08302 2 13
    Arrival MI321Kuala_Lumpur Kuala_Lumpur 09552 2 13
    Arrival MH601Kuala_Lumpur Kuala_Lumpur 09052 2 13
    Arrival MI802Darwin Darwin 19002 2 15
    Arrival MI804Darwin Darwin 06102 2 15
    Arrival NZ282Auckland Auckland 06453 3 8
    Arrival QZ262Jakarta Jakarta 09551 1 22
    Arrival SQ181Brunei Brunei 14053 3 14
    Arrival SQ278Adelaide Adelaide 16403 3 7
    Arrival SQ286Auckland Auckland 19003 3 8
    Arrival SQ298Christchurch Christchurch 17403 3 6
    Arrival SQ469Colombo Colombo 07553 3 9
    Arrival SQ801Beijing Beijing 06453 3 11
    Arrival SQ805Beijing Beijing 15203 3 11
    Arrival SQ807Beijing Beijing 23203 3 11
    Arrival SQ851Guangzhou Guangzhou 17403 3 13
    Arrival SQ853Guangzhou Guangzhou 05553 3 12
    Arrival SQ877Taipei Taipei 18503 3 15
    Arrival SQ931Surabaya Surabaya 13303 
     3 10
    Arrival SQ951Jakarta Jakarta 08103 3 3
    Arrival SQ953Jakarta Jakarta 11003 3 3
    Arrival TR227Jakarta Jakarta 12402 2 12
    Arrival TR298Guangzhou Guangzhou 14502 2 9
    Arrival TR299Taipei Taipei 00552 2 14
    Arrival UL302Colombo Colombo 13503 3 9
    Arrival UL306Colombo Colombo 07303 3 9
    Arrival UL308Colombo Colombo 18403 3 9
    What did I done wrongly?
    Last edited by MagicWand; 05-12-2016 at 09:21 AM.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,596
    I would start by creating a function to print out the information contained in your structures so you can verify that you're reading the file correctly.

    It appears to me that you're not reading the file correctly. Is it possible that your input file has non-printable characters embedded within it?


    Jim

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,596
    Also check your array sizes in your structures, don't forget that C-strings require a terminating character.

    You really really should consider using std::strings instead of the C-strings. If you stick to the C-strings then you should make sure you always limit the number of characters that will be retrieved to reduce the possibility of buffer overrun errors, such as those you're encountering now.

    Jim

  4. #4
    Registered User
    Join Date
    Apr 2016
    Posts
    12
    Thanks JimBlugBerg, it works now it is due to non-printable characters in the text file.

    I would like to sort this text file below as ascending order according to the time. The time is the 4 digits like 2305, 0745.

    Code:
    Departure 3K161 Darwin 2305 1 9 2 Boarding
    Departure 3K201 Jakarta 0745 1 8 2 Opened
    Departure 3K247 Surabaya 1140 1 7 2 Opened
    Departure 3K281 Medan 1040 1 7 2 Cancelled
    Departure 3K283 Medan 1510 1 7 2 Opened
    Departure 6E54 Chennai 0550 2 4 2 Cancelled
    Departure AF259 Paris 0105 1 5 4 Opened
    Departure AI347 Chennai 0915 2 4 3 Opened
    Departure BA12 London 2320 1 2 1 Boarding
    Departure BA15 Sydney 2005 1 7 1 Opened
    Departure BA16 London 2255 1 2 1 Opened
    Departure BR226 Taipei 1310 1 3 4 Opened
    Departure CI752 Taipei 1025 1 3 3 Cancelled
    Departure CZ3040 Guangzhou 1750 1 2 2 Opened
    Departure EK353 Dubai 1010 1 6 8 Opened
    Departure EK349 Dubai 0030 1 6 8 Opened
    Departure GA823 Jakarta 0725 3 11 3 Opened
    Departure GA855 Surabaya 2030 3 9 3 Opened
    Departure JT153 Jakarta 0945 3 9 6 Opened
    Departure KL836 Amsterdam 0130 1 4 7 Opened
    Departure KE642 Seoul 0130 2 6 4 Opened
    Departure LH779 Frankfurt 2355 3 4 3 Boarding
    Departure MH602 Kuala_Lumpur 0640 2 2 1 Opened
    Departure MI234 Medan 0730 2 3 1 Opened
    Departure MI238 Medan 1900 2 3 1 Opened
    Departure MI320 Kuala_Lumpur 0600 2 2 1 Opened
    Departure MI322 Kuala_Lumpur 0710 2 2 1 Opened
    Departure MI436 Chennai 0700 2 4 1 Opened
    Departure MI801 Darwin 1015 2 5 1 Opened
    Departure MI803 Darwin 2000 2 5 1 Opened
    Departure NZ281 Auckland 0850 3 11 2 Opened
    Departure QF6 Sydney 2350 1 9 5 Boarding
    Departure QF82 Sydney 1955 1 9 5 Opened
    Departure QZ263 Jakarta 1020 1 8 6 Opened
    Departure SQ2 San_Francisco 1830 3 7 1 Opened
    Departure SQ12 Los_Angeles 0920 3 7 1 Opened
    Departure SQ16 San_Francisco 0925 3 7 1 Opened
    Departure SQ211 Sydney 0940 3 12 1 Opened
    Departure SQ231 Sydney 0045 3 12 1 Opened
    Departure SQ241 Sydney 0705 3 12 1 Opened
    Departure SQ285 Auckland 2050 3 11 1 Opened
    Departure SQ295 Christchurch 2145 3 10 1 Opened
    Departure SQ297 Christchurch 1945 3 10 1 Opened
    Departure SQ306 London 0115 3 3 1 Opened
    Departure SQ318 London 1250 3 3 1 Opened
    Departure SQ324 Amsterdam 2355 3 6 1 Boarding
    Departure SQ326 Frankfurt 1355 3 4 1 Opened
    Departure SQ336 Paris 0010 3 2 1 Opened
    Departure SQ366 Rome 0110 3 8 1 Opened
    Departure SQ378 Barcelona 0140 3 5 1 Opened
    Departure SQ468 Colombo 2305 3 1 1 Boarding
    Departure SQ494 Dubai 1505 3 11 1 Opened
    Departure SQ608 Seoul 0010 3 1 1 Opened
    Departure SQ616 Osaka 1405 3 1 1 Opened
    Departure SQ618 Osaka 0130 3 1 1 Opened
    Departure SQ850 Guangzhou 0810 3 10 3 Opened
    Departure SQ876 Taipei 0830 3 2 1 Opened
    Departure SQ930 Surabaya 0750 3 9 1 Opened
    Departure SQ950 Jakarta 0645 3 10 1 Opened
    Departure TZ2 Sydney 0145 2 10 8 Opened
    Departure TR2260 Surabaya 1120 2 7 5 Opened
    Departure TR2274 Jakarta 0810 2 7 5 Opened
    Departure TR2634 Chennai 0740 2 4 5 Opened
    Departure TR2986 Guangzhou 0605 2 4 5 Opened
    Departure TR2988 Guangzhou 2140 2 2 5 Opened
    Departure TR2992 Taipei 0830 2 1 5 Opened
    Departure UL307 Colombo 1000 3 1 4 Opened
    Departure UL309 Colombo 1950 3 1 4 Opened
    Graphically, the array of pointers and the objects its element points to can be depicted as follow:

    Help needed on Read and Write Text file-screenshot_1-jpg

    Here is the requested way of doing using using array of pointers.

    Code:
    How to arrange the flight information in order?
    You can start with an array of pointer, which already has an (one) element in it. Note that an array with one element is always considered sorted because the order of that one element is correct.
    
    You now wish to insert a pointer to a new flight information structure. Two alternatives approach that you can insert the new pointer into the array correctly:
    
    - You can search starting from the first element of the sorted array of pointer and locate the right position to insert the new pointer.
    -  You can also search starting from the last element of the sorted array of pointer and locate the right position to insert the new pointer.
    But after reading it, I still don't understand how to do it. Can anyone explain to me? I'm a newbie in pointers.

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,596
    Please post your complete current code. Along with a small corrected input file.


    Jim

  6. #6
    Registered User
    Join Date
    Apr 2016
    Posts
    12
    Jim, here are all the files (complete current code) I got with the corrected input file. I need help on the sorting part. Thank You

    1. flightInfo.h


    Code:
    #include <iostream> // cout
    #include <fstream>  // fstream, ifstream, ofstream
    #include <iomanip>  // formatted output
    #include <ctime> // get time from OS
    #include <string.h> // strcat
    #include <sstream>
    #include <cstring>  // strcpy, strcmp
    #include <cstdlib>  // to include srand, rand
    
    
    using namespace std;
    
    
    const int FLIGHT_SIZE = 200;
    const int FLIGHT_NO_SIZE = 10;
    const int CITY_SIZE = 25;
    const int TIME_SIZE = 5;
    
    
    const char fileName[] = "flightInformation.txt";
    const char fileName2[] = "departureFlightInfoOut.txt";
    const char fileName3[] = "arrivalFlightInfoOut.txt";
    
    
    
    
    struct fDepartInfo {
        char dflightNo [FLIGHT_NO_SIZE]; // An alphanumeric code, not exceeding 10 characters, identifying a flight number.
        char originCity [CITY_SIZE]; // A character field, not exceeding 30 characters, identifying the origin city 
        char departTime [TIME_SIZE]; // A character field, not exceeding 4 characters, describing the departure time in 24 hours and minutes format.
        char terminalNo; // A single digit code indicating the terminal number.
        int gateNo; // An integer number indicating the gate number
        int checkInNo; // An integer number indicating the check-in counter
        char fStatus [30];
    };
    
    
    struct fArrivalInfo {
        char aflightNo [FLIGHT_NO_SIZE]; // An alphanumeric code, not exceeding 10 characters, identifying a flight number.
        char desCity [CITY_SIZE]; // A character field, not exceeding 30 characters, identifying the destination city.
        char arrivalTime [TIME_SIZE]; // A character field, not exceeding 4 characters, describing the arriving time in 24 hours and minutes format.
        char terminalNo; // A single digit code indicating the terminal number.
        int gateNo; // An integer number indicating the gate number
        int checkOutNo; // An integer number indicating the check-in counter
        char fStatus [30];
    };
    
    
    union fInfo {    
        fDepartInfo dFlight;
        fArrivalInfo aFlight;
    };
    
    
    struct Flight {
        char flightCode;
        fInfo fi;
    }; 
    
    
    int readFlightInfo (fstream&, Flight fInfo[]);
    void outputFlightInfo(fstream&, Flight fInfo[], int);
    2. fightInfoMain.cpp (to drive the functions in flightInfo.cpp)

    Code:
    #include "flightInfo.h"
    
    
    int main () {
      Flight fInfo [FLIGHT_SIZE]; // store flight information in array of pointers
      fstream afile, ofile; 
       
      int noOfRecords = readFlightInfo (afile, fInfo); // store the number of flight records read
       
      outputFlightInfo(afile, fInfo, noOfRecords);
        
      return 0; 
    }

    3. flightInfo.cpp

    Code:
    #include "flightInfo.h"
    
    
    // get info from studentInfo text file and store in array 
    int readFlightInfo (fstream& afile, Flight fInfo[]) {
         char extraKey; // to store extra hypens (-) on date of birth 
         
         // Open flight info text file for reading    
         afile.open (fileName, ios::in); 
         if (!afile) // if not afile
         {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
         }  
        
         
         cout << "--------------------------------------------------------" << endl;
         cout << fileName << " opened for reading" << endl;
         
         int i = 0;    // counter for looping
         while (afile >> fInfo[i].flightCode)
         {
            if (fInfo[i].flightCode == 'D')
            {
                    afile >> fInfo[i].fi.dFlight.dflightNo;
                    afile >> fInfo[i].fi.dFlight.originCity;    
                    afile >> fInfo[i].fi.dFlight.departTime;                
    
    
                    afile >> fInfo[i].fi.dFlight.terminalNo;
                    afile >> fInfo[i].fi.dFlight.gateNo;
                    afile >> fInfo[i].fi.dFlight.checkInNo; 
            
            }  else if (fInfo[i].flightCode == 'A')    {
                    afile >> fInfo[i].fi.aFlight.aflightNo;
                    afile >> fInfo[i].fi.aFlight.desCity;
                    afile >> fInfo[i].fi.aFlight.arrivalTime;    
    
    
                    afile >> fInfo[i].fi.aFlight.terminalNo;
                    afile >> fInfo[i].fi.aFlight.gateNo;
            }
            else {
                    cout << "There is no valid Flight Code in the text file!" << endl;
            }
    
    
            ++i;
            
            afile.clear(); 
            afile.ignore(1000, '\n'); // to ignore until newline
        }
    
    
        afile.close();
    
    
        cout << fileName << " closed successfully" << endl;
        cout << "--------------------------------------------------------" << endl;
    
    
        return i;    // i = number of flight records read
    }
    
    
    // Using the stored values in Flight array to generate arrival and destination text file
    void outputFlightInfo(fstream& afile, Flight fInfo[], int noOfRecords)
    {        
        fstream dfile;
        
        dfile.open(fileName2, ios::out);
        if (!dfile) // if not afile
        {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
        }  
        cout << "--------------------------------------------------------" << endl;
        cout << fileName2 << " created, containing arrival information." << endl;
        
        afile.open(fileName3, ios::out);
        if (!afile) // if not afile
        {
            cout << fileName << " opened for reading failed" << endl; // display reading of afile failed
            exit (-1); // cannot read the file successfully 
        }  
        
        time_t now;
        struct tm nowLocal;
        
        now = time (NULL); // get time from OS
        nowLocal = *localtime(&now);
        
        ostringstream currentTime; // stringstream
        if (nowLocal.tm_min < 10)
            currentTime << nowLocal.tm_hour << 0 << nowLocal.tm_min; // nowLocal.tm_min print 3 for 213 for 2103, so add a 0 become 2103
        else {
            currentTime << nowLocal.tm_hour << nowLocal.tm_min; // write to stream
        }
        
        istringstream iss(currentTime.str()); // convert to string
        int tempTime;                          // convert the result to integer
        iss >> tempTime;                      // write current time 
        
    
    
        for (int k = 0; k < noOfRecords; k++)
        {
                if (fInfo[k].flightCode == 'D')
                {
                        char fChance = rand() % 30 + 1; // range 1 to 30 
                        char fChance2 = rand() % 30 + 1; // range 1 to 30 
    
    
                        // convert depart time from character to integer
                        stringstream str;
                        str << fInfo[k].fi.dFlight.departTime;
                        int departTime;
                        str >> departTime;
                        
                        int timediff = departTime - tempTime;
                        
                        if (fChance == fChance2) { 
                            strcpy(fInfo[k].fi.dFlight.fStatus, "Cancelled");
                        } else if (departTime > tempTime && timediff > 60) {
                            strcpy(fInfo[k].fi.dFlight.fStatus, "Closed");
                        } else if (timediff >= 0 && timediff <= 60) {
                            strcpy(fInfo[k].fi.dFlight.fStatus, "Boarding");
                        } else {
                            strcpy(fInfo[k].fi.dFlight.fStatus, "Opened");
                        }
                        
                        dfile << "Departure " << fInfo[k].fi.dFlight.dflightNo << " "
                              << fInfo[k].fi.dFlight.originCity << " "
                              << fInfo[k].fi.dFlight.departTime << " "
                               << fInfo[k].fi.dFlight.terminalNo << " "
                              << fInfo[k].fi.dFlight.gateNo << " "
                              << fInfo[k].fi.dFlight.checkInNo << " "
                              << fInfo[k].fi.dFlight.fStatus << endl;
                }
                else if (fInfo[k].flightCode == 'A')
                {
                        // convert arrival time from character to integer
                        stringstream str2;
                        str2 << fInfo[k].fi.dFlight.departTime;
                        int arrivalTime;
                        str2 >> arrivalTime;
                            
                        if (arrivalTime > tempTime) {
                            strcpy(fInfo[k].fi.aFlight.fStatus, "Landed");
                        } else {
                            strcpy(fInfo[k].fi.aFlight.fStatus, "Confirmed");
                        }
                        
                        afile << "Arrival " << fInfo[k].fi.aFlight.aflightNo << " "
                              << fInfo[k].fi.aFlight.desCity << " "
                              << fInfo[k].fi.aFlight.arrivalTime << " "
                              << fInfo[k].fi.aFlight.terminalNo << " "
                              << fInfo[k].fi.aFlight.gateNo << " "
                              << fInfo[k].fi.aFlight.fStatus << endl;                          
                }
        }
        
    
    
        dfile.close();
        afile.close();
        cout << fileName2 << " written sucessfully" << endl;
        cout << "--------------------------------------------------------" << endl;
        cout << fileName3 << " written sucessfully" << endl;
        cout << "--------------------------------------------------------" << endl;
    }
    Here is the text file that the program will read to output the 2 files.



    flightInformation.txt file

    Code:
    D    3K161    Darwin    2305    1    9    2
    A    3K162    Darwin    0855    1    19
    D    3K201    Jakarta    0745    1    8    2
    A    3K202    Jakarta    1210    1    22
    D    3K247    Surabaya    1140    1    7    2
    D    3K281    Medan    1040    1    7    2
    A    3K282    Medan    1420    1    23
    D    3K283    Medan    1510    1    7    2
    A    3K284    Medan    1915    1    23
    A    3K684    Kuala_Lumpur    0950    1    25
    A    6E53    Chennai    0450    2    10
    D    6E54    Chennai    0550    2    4    2
    A    AF254    Paris    1510    1    18
    D    AF259    Paris    0105    1    5    4
    D    AI347    Chennai    0915    2    4    3
    A    AK701    Kuala_Lumpur    0710    1    25
    A    AK703    Kuala_Lumpur    0820    1    25
    D    BA12    London    2320    1    2    1
    D    BA15    Sydney    2005    1    7    1
    D    BA16    London    2255    1    2    1
    A    BI421    Brunei    1120    2    11
    A    BI423    Brunei    2035    2    11
    A    BR225    Taipei    1205    1    26
    D    BR226    Taipei    1310    1    3    4
    A    CA969    Beijing    2145    1    24
    A    CA975    Beijing    0630    1    24
    A    CI751    Taipei    2050    1    26
    D    CI752    Taipei    1025    1    3    3
    A    CI752    Surabaya    0925    1    20
    A    CI753    Taipei    1305    1    26
    A    CZ3039    Guangzhou    1650    1    25
    D    CZ3040    Guangzhou    1750    1    2    2
    D    EK353    Dubai    1010    1    6    8
    D    EK349    Dubai    0030    1    6    8
    A    GA822    Jakarta    0900    3    3
    D    GA823    Jakarta    0725    3    11    3
    A    GA824    Jakarta    1035    3    3
    A    GA854    Surabaya    1050    3    10
    D    GA855    Surabaya    2030    3    9    3
    A    IT511    Taipei    1435    2    14
    A    JT104    Surabaya    1120    3    10
    A    JT150    Jakarta    1105    3    3
    A    JT152    Jakarta    0900    3    3
    D    JT153    Jakarta        0945    3    9    6
    A    KL836    Bali    0000    1    21
    D    KL836    Amsterdam    0130    1    4    7
    A    KE641    Seoul    0010        2    8
    D    KE642    Seoul    0130    2    6    4
    D    LH779    Frankfurt    2355    3    4    3
    D    MH602    Kuala_Lumpur    0640    2    2    1
    A    MH609    Kuala_Lumpur    0005    2    13
    A    MI233    Medan    1105    2    9
    D    MI234    Medan    0730    2    3    1
    A    MI237    Medan    2220    2    9
    D    MI238    Medan    1900    2    3    1
    A    MI319    Kuala_Lumpur    0830    2    13
    D    MI320    Kuala_Lumpur    0600    2    2    1
    A    MI321    Kuala_Lumpur    0955    2    13
    D    MI322    Kuala_Lumpur    0710    2    2    1
    D    MI436    Chennai    0700    2    4    1
    A    MH601    Kuala_Lumpur    0905    2    13
    D    MI801    Darwin    1015    2    5    1
    A    MI802    Darwin    1900    2    15
    D    MI803    Darwin    2000    2    5    1
    A    MI804    Darwin    0610    2    15
    D    NZ281    Auckland    0850    3    11    2
    A    NZ282    Auckland    0645    3    8
    D    QF6        Sydney    2350    1    9    5
    D    QF82    Sydney    1955    1    9    5
    A    QZ262    Jakarta    0955    1    22
    D    QZ263    Jakarta    1020    1    8    6
    D    SQ2        San_Francisco    1830    3    7    1
    D    SQ12    Los_Angeles    0920    3    7    1
    D    SQ16    San_Francisco    0925    3    7    1
    A    SQ181    Brunei    1405    3    14
    D    SQ211    Sydney    0940    3    12    1
    D    SQ231    Sydney    0045    3    12    1            
    D    SQ241    Sydney    0705    3    12    1    
    A    SQ278    Adelaide    1640    3    7
    D    SQ285    Auckland    2050    3    11    1
    A    SQ286    Auckland    1900    3    8
    D    SQ295    Christchurch    2145    3    10    1
    D    SQ297    Christchurch    1945    3    10    1
    A    SQ298    Christchurch    1740    3    6
    D    SQ306    London    0115    3    3    1
    D    SQ318    London    1250    3    3    1
    D    SQ324    Amsterdam    2355    3    6    1
    D    SQ326    Frankfurt    1355    3    4    1
    D    SQ336    Paris    0010    3    2    1
    D    SQ366    Rome    0110    3    8    1
    D    SQ378    Barcelona    0140    3    5    1
    D    SQ468    Colombo    2305    3    1    1
    A    SQ469    Colombo    0755    3    9
    D    SQ494    Dubai    1505    3    11    1
    D    SQ608    Seoul    0010    3    1    1
    D    SQ616    Osaka    1405    3    1    1
    D    SQ618    Osaka    0130    3    1    1
    A    SQ801    Beijing    0645    3    11
    A    SQ805    Beijing    1520    3    11
    A    SQ807    Beijing    2320    3    11
    D    SQ850    Guangzhou    0810    3    10    3
    A    SQ851    Guangzhou    1740    3    13
    A    SQ853    Guangzhou    0555    3    12
    D    SQ876    Taipei    0830    3    2    1
    A    SQ877    Taipei    1850    3    15
    D    SQ930    Surabaya    0750    3    9    1
    A    SQ931    Surabaya    1330    3    10
    D    SQ950    Jakarta    0645    3    10    1
    A    SQ951    Jakarta    0810    3    3
    A    SQ953    Jakarta    1100    3    3
    D    TZ2        Sydney    0145    2    10    8
    D    TR2260    Surabaya    1120    2    7    5
    D    TR2274    Jakarta    0810    2    7    5
    A    TR2275    Jakarta    1240    2    12
    D    TR2634    Chennai    0740    2    4    5
    D    TR2986    Guangzhou    0605    2    4    5
    A    TR2987    Guangzhou    1450    2    9
    D    TR2988    Guangzhou    2140    2    2    5
    D    TR2992    Taipei    0830    2    1    5
    A    TR2997    Taipei    0055    2    14
    A    UL302    Colombo    1350    3    9
    A    UL306    Colombo    0730    3    9
    D    UL307    Colombo    1000    3    1    4
    A    UL308    Colombo    1840    3    9
    D    UL309    Colombo    1950    3    1    4
    Last edited by MagicWand; 05-13-2016 at 04:47 PM.

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    4,596
    You still need to check that the sizes of your arrays are large enough to hold the strings, currently there is at least one that is too small. You really really should consider using std::strings instead of the C-strings to make things easier.

    Code:
    Flight fInfo [FLIGHT_SIZE]; // store flight information in array of pointers
    Your comment is incorrect in the above line. You are not storing the flight information in an array of pointers you are storing the flight information in an array of fInfo that has a maximum size of FLIGHT_SIZE.

    I would also recommend that you either open the files in main() and pass an open stream into the functions or just create the file stream in the file and don't pass the unattached stream into the function.

    Lastly using exit() in a C++ program is not recommended because it doesn't properly call C++ class destructors, which can lead to corrupt data.

    Jim

  8. #8
    Registered User
    Join Date
    Apr 2016
    Posts
    12
    Quote Originally Posted by jimblumberg View Post
    You still need to check that the sizes of your arrays are large enough to hold the strings, currently there is at least one that is too small. You really really should consider using std::strings instead of the C-strings to make things easier.

    Code:
    Flight fInfo [FLIGHT_SIZE]; // store flight information in array of pointers
    Your comment is incorrect in the above line. You are not storing the flight information in an array of pointers you are storing the flight information in an array of fInfo that has a maximum size of FLIGHT_SIZE.

    I would also recommend that you either open the files in main() and pass an open stream into the functions or just create the file stream in the file and don't pass the unattached stream into the function.

    Lastly using exit() in a C++ program is not recommended because it doesn't properly call C++ class destructors, which can lead to corrupt data.

    Jim
    1. I'm using namespace std in the header file. Using std::strings, I do not need to include std::? How do I use strings in my program? Any example?

    2. If I changed to this with *, now it stores in a pointer of array right?
    Code:
    Flight *fInfo [FLIGHT_SIZE]; // store flight information in array of pointers
    3. Noted, I will open the files in main() and pass an open stream into the functions.

    4. In regards to sorting the time in ascending order in the text file.

    http://cboard.cprogramming.com/attac...reenshot_1-jpg

    Here is the instruction given, but I'm unsure of what it is asking about. Can you explain it?

    Code:
    How to arrange the flight information in order?
    You can start with an array of pointer, which already has an (one) element in it. Note that an array with one element is always considered sorted because the order of that one element is correct.
    
    You now wish to insert a pointer to a new flight information structure. Two alternatives approach that you can insert the new pointer into the array correctly:
    
    - You can search starting from the first element of the sorted array of pointer and locate the right position to insert the new pointer.
    
    -  You can also search starting from the last element of the sorted array of pointer and locate the right position to insert the new pointer.

    How do I sort this text file below as ascending order according to the time using the array of pointers. The time is the 4 digits like 2305, 0745.

    Code:
    Departure 3K161 Darwin 2305 1 9 2 Boarding
    Departure 3K201 Jakarta 0745 1 8 2 Opened
    Departure 3K247 Surabaya 1140 1 7 2 Opened
    Departure 3K281 Medan 1040 1 7 2 Cancelled
    Departure 3K283 Medan 1510 1 7 2 Opened
    Departure 6E54 Chennai 0550 2 4 2 Cancelled
    Departure AF259 Paris 0105 1 5 4 Opened
    Departure AI347 Chennai 0915 2 4 3 Opened
    Departure BA12 London 2320 1 2 1 Boarding
    Departure BA15 Sydney 2005 1 7 1 Opened
    Departure BA16 London 2255 1 2 1 Opened
    Departure BR226 Taipei 1310 1 3 4 Opened
    Departure CI752 Taipei 1025 1 3 3 Cancelled
    Departure CZ3040 Guangzhou 1750 1 2 2 Opened
    Departure EK353 Dubai 1010 1 6 8 Opened
    Departure EK349 Dubai 0030 1 6 8 Opened
    Departure GA823 Jakarta 0725 3 11 3 Opened
    Departure GA855 Surabaya 2030 3 9 3 Opened
    Departure JT153 Jakarta 0945 3 9 6 Opened
    Departure KL836 Amsterdam 0130 1 4 7 Opened
    Departure KE642 Seoul 0130 2 6 4 Opened
    Departure LH779 Frankfurt 2355 3 4 3 Boarding
    Departure MH602 Kuala_Lumpur 0640 2 2 1 Opened
    Departure MI234 Medan 0730 2 3 1 Opened
    Departure MI238 Medan 1900 2 3 1 Opened
    Departure MI320 Kuala_Lumpur 0600 2 2 1 Opened
    Departure MI322 Kuala_Lumpur 0710 2 2 1 Opened
    Departure MI436 Chennai 0700 2 4 1 Opened
    Departure MI801 Darwin 1015 2 5 1 Opened
    Departure MI803 Darwin 2000 2 5 1 Opened
    Departure NZ281 Auckland 0850 3 11 2 Opened
    Departure QF6 Sydney 2350 1 9 5 Boarding
    Departure QF82 Sydney 1955 1 9 5 Opened
    Departure QZ263 Jakarta 1020 1 8 6 Opened
    Departure SQ2 San_Francisco 1830 3 7 1 Opened
    Departure SQ12 Los_Angeles 0920 3 7 1 Opened
    Departure SQ16 San_Francisco 0925 3 7 1 Opened
    Departure SQ211 Sydney 0940 3 12 1 Opened
    Departure SQ231 Sydney 0045 3 12 1 Opened
    Departure SQ241 Sydney 0705 3 12 1 Opened
    Departure SQ285 Auckland 2050 3 11 1 Opened
    Departure SQ295 Christchurch 2145 3 10 1 Opened
    Departure SQ297 Christchurch 1945 3 10 1 Opened
    Departure SQ306 London 0115 3 3 1 Opened
    Departure SQ318 London 1250 3 3 1 Opened
    Departure SQ324 Amsterdam 2355 3 6 1 Boarding
    Departure SQ326 Frankfurt 1355 3 4 1 Opened
    Departure SQ336 Paris 0010 3 2 1 Opened
    Departure SQ366 Rome 0110 3 8 1 O

  9. #9
    Registered User
    Join Date
    May 2010
    Posts
    4,596
    If I changed to this with *, now it stores in a pointer of array right?
    Why use an array of pointers? Why use an array at all? Why not use a std::vector instead? This is C++ you should avoid pointers whenever possible.

    How do I sort this text file below as ascending order according to the time
    According to your instructions you should be inserting the records in the correct order.

    I'm using namespace std in the header file.
    Using the "using namespace std;" clause in a header file is a very bad practice, if you must use this clause keep it as local as possible. Also you should be including the correct header files in every file that requires them. Never rely on some other file to include a required include file.

    How do I use strings in my program?
    Replace all of your character arrays with strings. But you will need to #include <string> to use std::strings. You will also then not need <cstring> because you won't need strcmp(), strcat(), strcpy() or any of the other C-string functions. You should find and read some documentation for std::string if you're unsure how to use this class, there are quite a few tutorials available within a few keystrokes with any good search engine.

    Jim

  10. #10
    Registered User
    Join Date
    Apr 2016
    Posts
    12
    How do I insert the records in the correct order?

  11. #11
    Registered User
    Join Date
    Apr 2016
    Posts
    12
    Quote Originally Posted by jimblumberg View Post
    Why use an array of pointers? Why use an array at all? Why not use a std::vector instead? This is C++ you should avoid pointers whenever possible.


    According to your instructions you should be inserting the records in the correct order.


    Using the "using namespace std;" clause in a header file is a very bad practice, if you must use this clause keep it as local as possible. Also you should be including the correct header files in every file that requires them. Never rely on some other file to include a required include file.


    Replace all of your character arrays with strings. But you will need to #include <string> to use std::strings. You will also then not need <cstring> because you won't need strcmp(), strcat(), strcpy() or any of the other C-string functions. You should find and read some documentation for std::string if you're unsure how to use this class, there are quite a few tutorials available within a few keystrokes with any good search engine.

    Jim
    Jim, how do I insert records into array and arrange them in ascending order according to the arrival and departure time?

  12. #12
    Registered User
    Join Date
    Apr 2011
    Posts
    308
    To sort the file these are the steps:

    step 1.) open the file you want to sort and have an array with 8 elements. Then in a while loop you do this:

    Code:
    while(file>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7])
    {
    value_file << a[3] << endl; // a[3] is the time
    }
    step 2.) sort the file by putting the numbers in the file into an array and then using a function to sort the array least to greatest.
    Here is the sorting code:

    Code:
    void sort_least_to_greatest(int list[], int loop_counter)
    {
        int temp, i, j, n = loop_counter;
    
        // sorting code to find the largest value
    
                    // do the sorting...
                    for(i=0; i<n-1; i++)
                    for(j=i+1; j<n; j++)
                    if(list[i] > list[j])
                    {
                    // These three lines swap the elements
                    // list[i] and list[j].
                    temp = list[i];
                    list[i] = list[j];
                    list[j] = temp;
                    }
    }
    Now the largest value from the value_file will be the loop number -1 in the array holding the value_file numbers. What loop number, the one used when reading the value file in a while loop.
    Code:
    while(read_value_file >> number)
    {
    int x = stoi(number) // when I tried to do this the 0 number was erased, thats why I didn't write the code for you.
    array[counter] = x
    
    loop counter
    }
    Read the value file using a while loop, convert string to int, and save the int to an element of an int array. When doing this use a loop counter to show how many elements of the array were used to give to the sorting function.

    step 3.) open the file holding your input file you want sorted and using the array find the matching time in the file, then print this to a new file.
    Then go to the next lowest array value and find that value in the file you want sorted, and when you find a match compare it to the new file to see if its already in the new file, if it isn't then write it to the new file.
    Keep doing this until you go through the whole int array holding the sorted values from least to greatest, then the new file will hold your sorted list.
    Last edited by jeremy duncan; 05-15-2016 at 12:00 AM.

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jeremy duncan View Post
    step 2.) sort the file by putting the numbers in the file into an array and then using a function to sort the array least to greatest.
    Or you can just use std::sort with a lambda that specifies the sorting order.
    Also, handing out solutions isn't the best way for one to learn.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encoding text also file write read problem
    By Ph0x in forum C Programming
    Replies: 2
    Last Post: 10-08-2014, 07:59 PM
  2. Replies: 2
    Last Post: 11-29-2012, 11:45 PM
  3. Replies: 12
    Last Post: 06-18-2012, 08:23 AM
  4. Read text file line by line and write lines to other files
    By magische_vogel in forum C Programming
    Replies: 10
    Last Post: 01-23-2011, 10:51 AM
  5. Help is needed to read text from a file
    By yuzhangoscar in forum C Programming
    Replies: 12
    Last Post: 09-12-2008, 12:10 AM

Tags for this Thread