As Dani's @ tinstaafl suggests ...

firstly ...

to get a design for just simple addition (of large int's of any size) to work,

you could use some functions to read in dynamic C strings of any size, maybe something like this:

Note that file "readLIne2.h" is available here:

http://developers-heaven.net/forum/index.php/topic,2582.msg3143.html#msg3143

/* add_dynamic_Cstrings.c */

#include "readLine2.h"

/* 2 handy utilities here ... */
int takeInChr( const char* msg )
{
    char chr;
    fputs( msg, stdout ); fflush( stdout );
    chr = getchar();
    if( chr != '\n' ) while( getchar() != '\n' ) ; /* flush stdin ... */
    return chr;
}
int more() /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */
{
    if( tolower( takeInChr( "More (y/n) ? " )) == 'n' ) return 0;
    /* else ... */
    return 1;
}

int is_valid( const char* str )
{
    while( *str )
    {
        if( *str < '0' || *str > '9' ) return 0;
        ++str;
    }
    return 1;
}

char* add( const char* a, unsigned len_a, const char* b, unsigned len_b, unsigned* len_c )
{
    char* c;
    int i, j;
    int overflow = 0;
    if( len_a >= len_b )
    {
        c = newMem( len_a+1 );
        c[len_a] = 0;
        for( i = len_a-1, j = len_b-1; j >= 0; --i, --j )
        {
            c[i] = a[i] + (b[j] - '0') + overflow;
            if( c[i] > '9' )
            {
                overflow = 1;
                c[i] -= 10;
            }
            else
            {
                overflow = 0;
            }
        }

        for( ; i >= 0; --i ) ...

You seem to be using C++ ... so use C++ string ...
(and this question should then be in the C++ forum.)

Another way to get the string you need is to use an array of strings (a table) ...
See the example below:

// return_a_string.cpp//

#include <iostream>
#include <iomanip> // re. setw
#include <string>  // use C++ string in C++ //
#include <sstream> // re. stringstream objects //
#include <cctype> // re. tolower //

using namespace std;

const string DELIVERY[] =
{
    "UNKOWN", "BlueDart", "FedEx", "Delhivery", "DTDC/FirstFlight",
    "Ecom Express", "India Post", "ATS", "Ekart", "Aramex"
} ;
const int NUM_DELIVERY_TYPES = sizeof DELIVERY / sizeof *DELIVERY;

const string CHOICES[] =
{
    "", "Baby & Mom", "Books & Magazines", "Cameras & Optics", "Automotive",
    "stringity", "Clothing & Accessories", "Coins & Notes", "Collectibles",
    "Fitness & Sports", "Fragrances, Beauty & Health", "Fun Stuff", "Games & Accessories",
    "Home and Living", "Home & Kitchen Appliances", "Jewellery & Precious Coins", "Kitchen & Dining",
    "Laptops & Computer Peripherals", "LCD, LED & Televisions", "Memory Cards, Pen Drives & HDD", "Mobile Accessories",
    "Mobile Phones", "Gaming Consoles", "Movies & Music",  "Musical Instruments", "Services & Real Estate",
    "Shoes", "Stamps", "Stationery & Office Supplies", "Tablets & Accessories",
    "Hardware & Electricals", "Toys, Games & School Supplies", "Travel", "Watches", "Warranty Services", "Wearable Devices",
    "Audio & Home Entertainment", "Everything Else"
} ;
const int NUM_CHOICES = sizeof CHOICES / sizeof *CHOICES;

template< typename T >
T takeIn( const string& msg )
{
    T val;
    while( true )
    {
        cout << msg << flush;
        if( cin >> ...

There are few things about your style of coding that could be improved:

/* use Global const (in C use #define) instead of 'magic numbers' */
#define MAX_LEN 31 /* pick numbers that give multiplies of 4 (or 8) bytes */ 

typedef struct
{
    char name[MAX_LEN+1], /* recall need space for terminal 0 */
         surname[MAX_LEN+1];
    int number;

} Player ; /* Use Cap then small case here */

typedef struct
{
    char nameofteam[MAX_LEN+1];
    int numberofplayers;
    Player* players;

} Team ;

/* 
Note: usually it is better to pass in data records by passing the address.
 */
void pr_replaces_numout( Team* tm, const Player* pr, int numout )
{
    int i;
    for( i = 0; i < tm->numberofplayers; ++ i )
    {
        if( tm->players[i].number == numout )
        {
            strcpy( tm->players[i].name, pr->name );
            strcpy( tm->players[i].surname, pr->surname );
            tm->players[i].number = pr->number;
            break;
        }
    }
}

There are several steps to the final solution of your problem ...

The first step that I would suggest you take would be to get some test data,
perhaps like this ... to get a bin file to test the rest of your code:

/* spiltInto2Files.c */

#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* strcmp */

#define MAX_STR_LEN 19
#define FORMAT_STR_IN " %19s %19s %19s %19s %lf"
#define FORMAT_STR_OUT "%-19s %-19s %-19s %-19s %10.2f\n"

const char* START_TXT = "start.txt";
/*
12345 Samuels Joe Prof 60000
12348 Plummer Bob Assist 30000
12347 Anderson Kim Assist 25000
12344 Davidson George Prof 110000
12346 Bowers Ann Assist 20000
*/

const char* TEST_BIN = "test.bin";

const char* PROF_FILE   = "prof.txt";
const char* ASSIST_FILE = "assist.txt";

typedef struct
{
   char id[MAX_STR_LEN+1],
        surname[MAX_STR_LEN+1],
        name[MAX_STR_LEN+1],
        title[MAX_STR_LEN+1];
   double salary;

} Employee ;

int create_bin_file( const char* fname_in, const char* fname_out)
{
    FILE* fin  = fopen( fname_in, "r" );
    FILE* fout = fopen( fname_out, "wb" );
    if( fin && fout )
    {
        char buf[128];
        Employee tmp;
        while( fgets( buf, sizeof buf, fin ) )
        {
            if( sscanf( buf, FORMAT_STR_IN, tmp.id, tmp.surname, tmp.name, tmp.title, &tmp.salary ) != 5 )
                return 0;;
            /* size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream ); */
            if( fwrite( (char*)&tmp, sizeof(Employee), 1, fout ) != 1 )
                return 0;
        }
        fclose( fout );
        fclose( fin );
        return 1;
    }
    /* else */
    printf( "Error opening files ...\n" );
    return 0;
}

After that, you should test that the bin ...

All you need to do is change the print function to a ....
get and fill array function ...
like this:

void get_positions( const int* ary, int size, int val, int* pos_ary )
{
    int i, j = 0;
    for( i = 0; i < size; ++ i )
    {
        if( ary[i] == val )
            pos_ary[j++] = i;
    }
}

Then, you could update the main function, to be like this:

int main()
{
    int arr[] = { 14, 10, 2, 1, 14, 1, 10, 14, 14, 2, 3, 4, 14, 14, 1, 4, 14, 14 };
    int size = sizeof arr / sizeof *arr ;
    int i, i_mc, size_vc_ary = 0;

    ValCount* vc_ary = malloc( sizeof(ValCount) * size );

    if( vc_ary )
    {
        int* pos_ary;

        for( i = 0; i < size; ++ i )
            size_vc_ary = update( vc_ary, size_vc_ary, arr[i] );

        i_mc = get_i_of_max_count( vc_ary, size_vc_ary );

        printf( "The most frequent value was %d and it occured %d times.\n",
                vc_ary[i_mc].val, vc_ary[i_mc].count );
        printf( "The value %d occured at positions: ", vc_ary[i_mc].val );

        pos_ary = malloc(sizeof(int) * vc_ary[i_mc].count );
        if( pos_ary )
        {
            get_positions( arr, size, vc_ary[i_mc].val, pos_ary );

            for( i = 0; i < vc_ary[i_mc].count; ++ i )
            {
                printf( "%d ", pos_ary[i] );
            }
            /* free up all dynamic memory when done with it */
            free( pos_ary );
        }

        /* free up all dynamic memory when done with it */
        free( vc_ary );
    }

    printf( "\n\nPress 'Enter' to continue/exit ... " );
    fflush( stdout );
    return 0; ...

You could form a string and print the reversed string ...
(i.e. similar to using a 'stack' to unwind the recursive calls)
like this:

#include <stdio.h>

/*
    Write an iterative function char* conversion(unsigned int num, int base),
    that converts an integer num into any base (base <=10).

    How to transform the following recursive function conversion() 
    into (an) iterative:
*/

void conversion( unsigned num, unsigned base )
{
    if( num / base )
        conversion( num / base, base );
    printf( "%u", num % base);
}

/* assumes number is greater than base ... */
void conversion_iterative( unsigned num, unsigned base )
{
    char buf[64]; /* make extra large enough to hold digits */
    int i = 0, size = 0;
    while( num / base )
    {
        buf[size++] = num % base + '0';
        num /= base;
    }
    buf[size++] = num % base + '0';
    buf[size] = 0; /* '\0' terminate */

    /* now reverse string */
    --size;
    while( i < size )
    {
        char tmp = buf[i];
        buf[i] = buf[size];
        buf[size] = tmp;
        ++i, --size;
    }
    printf( "%s", buf );
}

int main()
{
    unsigned num, base;
    printf( "num = " );
    if( scanf( "%u", &num ) == 1 && getchar() == '\n' )
    {
        do
        {
            printf( "base = " );
            if( scanf( "%u", &base ) != 1 )
            {
                printf( "Numbers only here please in range 2..10\n" );
                while( getchar() == '\n' ); /* flush 'stdin' ... */
            }
        }
        while( base < 2 || base > 10 ); ...

I would use a struct (with a typedef) to create a data record to track the frequencies of each value in the int array.

Maybe something like this ...

Firstly:

/* most_frequent.c */

#include <stdio.h>
#include <stdlib.h> /* re. malloc */

typedef struct
{
    int val;
    int count;
} ValCount ;

Then some functions:

int update( ValCount* ary, int size, int val )
{
    int i, found = 0;
    for( i = 0; i < size; ++i )
    {
        if( ary[i].val == val )
        {
            ++ary[i].count;
            found = 1;
            break;
        }
    }
    if( !found )
    {
        ValCount tmp;
        tmp.val = val;
        tmp.count = 1;
        ary[size] = tmp;
        ++size;
    }
    return size;
}

int get_i_of_max_count( const ValCount* ary, int size )
{
    int i, i_mc = 0;
    for( i = 1; i < size; ++ i )
    {
        if( ary[i].count > ary[i_mc].count ) i_mc = i;
    }
    return i_mc;
}

void print_positions( const int* ary, int size, int val )
{
    int i;
    for( i = 0; i < size; ++ i )
    {
        if( ary[i] == val ) printf( "%d ", i );
    }
}

Then the main function could be like this:

int main()
{
    int arr[] = { 14, 10, 2, 1, 14, 1, 10, 14, 14, 2, 3, 4, 14, 14, 1, 4, 14, 14 };
    int size = sizeof arr / sizeof *arr ;
    int i, i_mc, size_vc_ary = 0;

    ValCount* vc_ary = malloc( sizeof(ValCount) * size );

    if( vc_ary )
    {
        for( i = 0; ...

I would re-think what you are trying to do?

This example of a 'class Cube' may give you some ideas re. a simpler design.

example of a test main file:

// cube_test.cpp //

#include "cube.h"

int main()
{
    Cube cu( Point(0, 0, 0), 1 );
    cu.show();

    printf( "Press 'Enter' to continue/exit ... " ); fflush( stdout );
    getchar();
}

.h file:

// cube.h //

#ifndef CUBE_H
#define CUBE_H

#include <cstdio>

struct Point
{
    int x, y, z;

    Point( int x=0, int y=0, int z=0 ) : x(x), y(y), z(z) {}

    void print() const
    {
        printf( "(%d, %d, %d)\n", x, y, z );
    }
} ;

class Cube
{
public:
    Cube( const Point& pt, int cwidth );
    void show() const;
private:
    int width;
    Point corner[2][2][2];
} ;

#endif;

.cpp file:

// cube.cpp //

#include "Cube.h"

Cube::Cube( const Point& pt, int cwidth ) : width(cwidth)
{ 
    for( int ix = 0; ix < 2; ++ix )
    {
        for( int iy = 0; iy < 2; ++iy )
        {
            for( int iz = 0; iz < 2; ++iz )
                corner[ix][iy][iz] = Point( pt.x + ix*cwidth, pt.y + iy*cwidth, pt.z + iz*cwidth );
        }
    }
}

void Cube::show() const
{
    for( int ix = 0; ix < 2; ++ix )
    {
        for( int iy = 0; iy < 2; ++iy )
        {
            for( int iz = 0; iz < 2; ++iz )
            {
                corner[ix][iy][iz].print();
            }
        }
    }
}

Look at the
'if ... else ...'
examples I gave you of different tests
and branching to different sections
by set / reset of 'flag' values
and see if you can code the exact solution that you wish?

If you get stuck ...
take a deep breath and 'think'

If ( condition is true ) do this
else do that

and try again ...
and if still stuck ... show the code you tried.

... but i missed the part where if a player rolls a 1,
the score should not be added to his total so it'll be the second players to roll.
i couldnt seem to get that command to work so far;
any idea?

Take a look at this demo ... that has ADDED EXTRA ROLLS for the 'computer' ...
if the 'computer rolls' certain values ...

/* rollDice2.c */  /* 2015-10-15 */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

/*
     ... i missed the part where if a player rolls a 1,
     the score should not be added to his total
     so it'll be the second players to roll.
     i couldnt seem to get that command to work so far;
     any idea?

     BUT added here...
     if computer rolls 1, 3, 5 then computer rolls again ...
*/

/* prototypes for 3 handy utilities for many C student coding problems ... */

/* a simple student way to handle numeric input ...
   so program won't crash on bad input */
int takeInInt( const char* msg );
int takeInChr( const char* msg );
int more(); /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */

void showDice( int randNum );
void playGame();

int main() /* ******************************************* */
{
    do
    {
        playGame();
    }
    while( more() );

    return 0;
} /* **************************************************** */

void playGame()
{
    int gameTotal = 0, player = 0, computer = 0;
    char choice = 'p'; /* start with player, 'c' is for computer */

    srand( ...

See example solutions to common beginner problems ...

1) take in valid int (with a prompt) so program won't crash
2) keep stdin flushed as you go ...
3) loop while more
4) takeInChr( withpromptStr ) to ease getting user choices

This demo may help you get started with clean working code ...

Note:
This demo does NOT entirely conform to the spec's you were given,
but is meant to help you get started.

/* rollDice.c */

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void showDice( int randomNumber );
void playGame();

/* 3 handy utilities for many C student coding problems ... */
int takeInChr( const char* msg );
int more(); /* defaults to 'true'/'yes'/'1' ... unless 'n' or 'N' entered */
/* a simple student way to handle numeric input ...
   so program won't crash on bad input */
int takeInInt( const char* msg );

int main()
{
    do
    {
        playGame();
    }
    while( more() );

    return 0;
}

void playGame()
{
    int gameTotal = 0, player = 0, computer = 0;
    char choice = 'p'; /* start with player */

    srand( time(0) ); /* seed rand... */

    printf( "Welcome to the GAME of PIG ... \n\n" );

    gameTotal = takeInInt( "Enter the game total (for example 40): " );

    while( player < gameTotal && computer < gameTotal )
    {
        char roll;
        if( choice == 'p')
        {
            printf( "It's time for player ... \n" );
            do
            {
                roll = takeInChr( "Your choice roll or hold (r/h) ? " );
            }
            while( ...

You need to start coding, implementing the steps you were given ...

and then to show us the code you tried.

Re. the unclear graphic output part ... you will have to clear that up with the source.

Is your expanded problem to process multiple files in a folder?

If so, then you could modify the example to be looking for the (input) .txt file names from standard input ...

Then ... perhaps ....
write a batch file, (that calls that compiled modified program .exe file), to process ALL the .txt files in that folder ...

After each file was processed, it would yield/output the corresponding .csv file.

Test this code:

// call string constructor
string test2( "good better best" );

// call istringstream constructor
istringstream is( test2 );

string x,tmp,z;
// extract words/strings from is object
is >> x >> tmp >> z;

// show best good backwards
cout << z << ' ' << x;

Can you test this code ?

cout << "Enter 3 words separated by a space: ";
string a,b,c;
cin >> a >> b >> c;
cout << "You entered: " << a << " and " << b << " and " << c << endl;

Do you see how the extraction operator >> works with a cin stream?

istringstream objects are 'string streams' that via the extraction operator >> you can extract strings (or other types) from the stream.

In C++ you need to write your own code to print out the elements of an array ...

string test = "a BB ccc";
istringstream iss( test );
string str[3];
iss >> str[0] >> str[1] >> str[2];
// try this ... or code a loop
cout << str[0] << ',' << str[1] << ',' << str[2];

iss >> tmp; //is getting the next line?

No ... getting the next item.

string test = "a BB ccc";
istringstream iss( test );
string str[3];
iss >> str[0] >> str[1] >> str[2];

What do you think is now in each array element?

Can you write a short program to test this out ... and see what happens?

Did you try out the working code I provided?

Did you read the comments in the code and try to follow the steps?

If you do not take time to read the instructions and follow them ... then why should I take any more time with you?

You have already been given a working C++ example solution ... if you are really sincere about learning to program in C++, then ... you really do need to start at the beginning ... as I previously indicated, and even provided some links to help you to start.

For example ... if I were to attempt to talk to you about 'entropy' and the 2nd law of thermodynamics ... before you had studied 'energy' ( / 'heat' / 'work' ) and the 1st law of thermodynamics ... and 'the atomic nature' of all matter ... and the concept of 'temperature' ... would you be able to understand and solve problems that related to the concept of 'entropy' ?

http://developers-heaven.net/forum/index.php/topic,2587.msg3103.html#msg3103

This code of yours:

string PK; // stands for primary key;
while ( getline( fin, line) && PK++ > 1);
PK = 98;

does NOT make any sense at all!

If PK is a C++ string,
then the default value (when constructed as you have coded)
is "", i.e. the empty string, and then this code:

PK++ makes NO sense at all!

But ...

PK += "Sam"; 
// this code makes sense, it 'concatenates' the string "Sam" 
// to the end of the empty string PK ... 
// so that PK then becomes "Sam" //

And then trying to compare a C++ string value to an int of value 1 ...
this reveals that you are really terribly mixed up,
and NOT understanding even C++ coding basics!

You need to start at the beginning and learn to program step by step.
(Study the 6 fast steps link I gave you previously ...)
There are many beginning C++ tutorials on line ...

Try this slower paced one:

http://developers-heaven.net/forum/index.php/topic,127.0.html

Where did you get this problem of extracting data from source files structured as you have suggested ... to produce the particular extracted csv data file you seem to want?

But take a look ...
this is how one might code a solution ...
after your last 'hint' ...
about the way the data is structured in the input data file:

// fileReadWrite3.cpp //  // 2015-08-26 //

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

/*
    Hint:

    The code might be a little ...

Hint : the code might be a little simpler ... Read / discard 1st 3 lines ...
Then read a line ... and while exists next line and next line does not begin with "86" append to first line
Otherwise have first line of next rec... So process prev rec / 'extended line' and output the extracted data from this 'extended line'

NO!

This code: while( iss >> tmp && tmp.substr(0,3) != "333" ) ;
will be my reference I change 333 to 98, But I don't know where to put ...

NO!!! Leave that as is, since that was a part of your program data extraction specifications.

You need to think about what your program is supposed to do ... at each step ... and thus what edit(s) to make to example???

If you wish to process several files, each with the very same structure as the first, you could store the names in an array or an other C++ container like a vector, and then loop though each file name to process that file in turn ... while outputting processed data to files (or appending to a common output file if that was what you want.)

But ... get your code working perfectly ok for ONE representative example input file firstly !!!

The raw data file NEEDs to be 'massaged' to be regular to be read ok ...

IF these TWO lines are FIXED ...

It seems to be ALL read ok.

AUG.02, 2015
SMPH01 RPMM 020000
AAXX 02001
98132 31462 21101 10293 20264 40145 53020 70540 82100 33302 20255 56399 59004 82817 ='01
rh93/76 rmks 255 2am, fe.
98133 31467 20902 10300 20270 40109 5//// 70544 82200 222// 20501 33301 20255 56299 58002
82818 MJ. RMK.RH=90/80 MIN.=25.5 8AM
98134 32465 21002 10287 20253 39928 40114 53013 82200 33301 20250 56999 58002 82819 ='12
max=305@0600z min=250@1800z rh=87/79 MP
98222 31570 10201 10284 20242 40114 51007 70544 81200 33301 20249 56999 59002 81820 ='01
occurance of min. Temp. 2210z ca
98223 31460 21101 10288 20259 40103 52013 70540 81205 33301 20240 56999 58006 81819 ='08
RH 96/47 TMIN 24.0 @ 5:30 A.M. TAFOR RPLI 0606 32006KT 9999 FEW019 TEMPO 0612 32008KT 9999 FEW019 SCT100 RPLI 020000Z 11002KT 9999 FEW019TCU 29/26 Q1010 NOSIG RMK A2982 TCU W RPG
98232 31570 30000 10279 20246 30109 40112 53009 70500 81100 222// 20100 33302 20262 56999
58007 81820 RH92/65 MAX.TEMP.33.0@0600Z MIN.TEMP.26.2@2200Z REM.SLIGHT SEA ET'09
98233 31568 50000 10253 20234 40121 53024 70540 83230 33302 20240 56999 58010 83820 85358='08
T MIN = 24.0 @ 5:40 AM, MX RH = 90%, MN RH = 65% MLT
98324 11462 40901 10280 20251 40107 53013 60084 70544 82211 33312 20244 56929 58006 70084 82816
83358 CC MIN TEMP 24.4 AT 2100
98325 31462 31601 10278 20252 40101 53011 70592 83970 ...

You need to have the file it is looking for ... available.

For ease of access, place the file to be read in the same folder as your compiled .exe (executable) file.

Did you NOT see the comments ?

const char* FILE_IN  = "rawDataForExcel.txt";
const char* FILE_OUT = "selectedData.csv";
// example of 'in file'
/*
    AUG.02, 2015
    SMPH01 RPMM 020000
    AAXX 02001
    98132 31462 21101 10293 20264 40145 53020 70540 82100 33302 20255 56399 59004 82817 ='01
      rh93/76 rmks 255 2am, fe.
    98133 31467 20902 10300 20270 40109 5//// 70544 82200 222// 20501 33301 20255 56299 58002
     82818 MJ. RMK.RH=90/80 MIN.=25.5 8AM
    98134 32465 21002 10287 20253 39928 40114 53013 82200 33301 20250 56999 58002 82819 ='12
      max=305@0600z min=250@1800z rh=87/79 MP
    98222 31570 10201 10284 20242 40114 51007 70544 81200 33301 20249 56999 59002 81820 ='01
      occurance of min. Temp. 2210z ca
*/

The demo program, as above, IS looking for a file with the name:

"rawDataForExcel.txt"

So ...

Make sure a file with the above contents is there ... and called by that name!

You really do not need to read the processed records into a vector ...

I would keep it simple ... something like this:

// fileReadWrite.cpp //

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

using namespace std;

const char* FILE_IN  = "rawDataForExcel.txt";
const char* FILE_OUT = "selectedData.csv";

// example of 'in file'
/*
    AUG.02, 2015
    SMPH01 RPMM 020000
    AAXX 02001
    98132 31462 21101 10293 20264 40145 53020 70540 82100 33302 20255 56399 59004 82817 ='01
      rh93/76 rmks 255 2am, fe.
    98133 31467 20902 10300 20270 40109 5//// 70544 82200 222// 20501 33301 20255 56299 58002
     82818 MJ. RMK.RH=90/80 MIN.=25.5 8AM
    98134 32465 21002 10287 20253 39928 40114 53013 82200 33301 20250 56999 58002 82819 ='12
      max=305@0600z min=250@1800z rh=87/79 MP
    98222 31570 10201 10284 20242 40114 51007 70544 81200 33301 20249 56999 59002 81820 ='01
      occurance of min. Temp. 2210z ca
*/

struct CSV
{
   string ary[10]; // A,B,C,D,E,F,G,H,I,J; //

   // returns 0, or 1 if NEXT line is read in already //
   int extract( istream& fin, const string& str )
   {
       istringstream iss( str );
       string tmp;
       iss >> tmp;
       ary[0] = tmp.substr(0,2);
       ary[1] = tmp.substr(2);

       iss >> tmp;
       ary[2] = tmp.substr(0,1);
       ary[3] = tmp.substr(1,3);
       ary[4] = ary[5] = ary[6] = ary[7] = ary[8] = ary[9] = "x";

       for( int i = 0; i < 6; ++ i )
            iss >> tmp; // skip over 3,4,5,6,7 and read 8
       ary[4] = tmp.substr(0,1);
       ary[5] = tmp.substr(1,3);

       iss >> tmp;
       ary[6] = tmp.substr(0,1);
       ary[7] = tmp.substr(1,3);

       while( iss >> tmp && tmp.substr(0,3) ...

Show us the code you have tried so far ... for this:

You could read/skip the first 2 lines ... Then read (in pairs of) 2 lines, skipping over that first line and parsing the 2nd line ... till done ... You could use stringstream objects to ease parsing each line of numbers you wish to parse ... (as per the examples at the link provided.)

To start, you could look at the file read/parse examples here:

http://developers-heaven.net/forum/index.php/topic,2019.0.html

You could read/skip the first 2 lines ...
Then read 2 lines, skipping over that first line and parsing the 2nd line ... till done

You could use stringstream objects to ease parsing each line of numbers you wish to parse.

Your code would be so much more C++ like if you could follow the example of Dani's @NathanOliver ...

But if you really have to use C strings and pointers to char ... (in a C++ program) ...you could try something like this:

// split2.cpp //

#include <iostream>
#include <sstream> // re . istringstream object //
#include <string>
#include <vector>

#include <cstdlib> // malloc
#include <cstring> // re. strchr, etc... //

using namespace std;

// using stringstream objects //
void toToks( vector< string >& v, const string& line, const char delimit = '|' )
{
    istringstream iss( line ); // construct istringstring object 'iss' from string 'line'
    string tmpTok;
    while( getline( iss, tmpTok, delimit ) )
        v.push_back( tmpTok ); // push back a copy //
}

// using strchr and passing in C strings //
void toToks2( vector< string >& v, const char* line, const char delimit = '|' )
{
    const char* p1 = strchr( line, delimit );

    while( p1 )
    {
        int size = p1-line;
        char* str = (char*) malloc (sizeof(char) * (size+1));
        if( !str )
        {
            cout << "\nAn ERROR occured in calling malloc ...\n\n";
            return;
        }
        strncpy( str, line, size );
        str[size] = 0;

        v.push_back( str ); // push back a C++ string copy //
        free( str );

        while( *p1 && *p1 == delimit ) ++ p1;
        if( *p1 )
        {
            line = p1;
            p1 = strchr( line, delimit );
        }
        else break;
    }
}

int main ()
{
    cout << "Preferred 'method 1' using C++ ...

You might like to use some C++ library functions to assist parsing a line ...

http://developers-heaven.net/forum/index.php/topic,2019.msg2682.html#msg2682