Need some help with this code / Using UNIX.
The goals is to read a big file (2,000,000) lines, using fork() to create children to help in the process.
I am able to get the program (C++) running and this is what it does:
1) creates the number of children the user indicates
2) can read the number lines in the TXT file
3) tells how many lines each child will read
This is how I understand what the program will do and I want to make sure thatI am right or wrong:
As an example, lets assume that we have: 2 children & 10 TXT lines, each child will read five lines.
When the loop creates a child, that child will go to the TXT file will read its own set of lines (in this case 5) and will copy them to the pipe. After this, the loop will continue and each new child will do the same, with its own set of lines.
Is this correct?...
If this is correct... then I need help in defining the propper way to have the 2nd child created, continue reading the next line, meaning:
Child 1 reads lines: 0,1,2,3,4
Child 2 reads lines: 5,6,7,8,9 <<< how to make the second child go to the proper line to start?
I know that the seekg method goes to a specific line, still I am having problems adding this functionallity to the code.
Please advise...
Thank you...