View Single Post
Old 10-10-2008, 06:37 AM   #1
Data
retired
 
Data's Avatar


 
Join Date: Jun 2004
Location: Jan Mayen, Svalbard and Jan Mayen
Posts: 2,167
Default

the only thing I can think of is the line ends being different. I did convert them to unix line ends. It shouldn't matter as I compiled the executable for windows, but maybe that doesn't convert the line ends internally afteral, or maybe it needed a switch.

I used C++ to program it, it is a quick getting the job done piece of code.

Let me post it here. Don't bother with pointing out all C-isms and other things which I could have done better. I know them myself as well.
Code:
/* Copyright Data */

#include <string>
#include <iostream>

int main (int argc, char *argv[]) {
        std::string templine;
        std::string index, timeindex, text;
        std::string index2, timeindex2, text2;

        //Get initial record:
        getline (std::cin, index);
        getline (std::cin, timeindex);
        templine = "";
        do {
                getline (std::cin, templine);
                text += templine;
                text += "\n";
        }
        while (templine != "");

        while (std::cin) {
                getline (std::cin, index2);
                getline (std::cin, timeindex2);
                templine = "";
                do {
                        getline (std::cin, templine);
                        text2 += templine;
                        text2 += "\n";
                }
                while (templine != "");

                //writeout record:
                std::cout << index << std::endl;
                std::cout << timeindex << std::endl;
                std::cout << text2;

                //move up:
                index = index2;
                timeindex = timeindex2;
                text2 = "";
        }
        return 0;
}
__________________
Flowing with the stream of life

Last edited by Data; 10-10-2008 at 06:39 AM.
Data is offline                         Send a private message to Data
Reply With Quote