I run the code in both Windows and Linux. In Window, I can get result I intended but, in Linux, I get different result with one I get from Window.
What causes this difference and how to fix the code in Linux?
Thanks a lot! :) I attached the code, input, and result from both OS.
Below is my code; (This code is to reversely order the components with dots and differentiate components using a slash.)
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
string set_name = "6000k";
// in
string raw_file = set_name + "_filtered.txt";
// out
string set_file = set_name + "_filtered_dot.txt";
// main
int main()
{
    int i = 0;
    string comp = ""; 
    string str; 
    vector<string> input_comp;
    vector<string> tmp_comp; 
    int input_order = 0;
    ifstream infile;
    infile.open(raw_file);
    ofstream outfile;
    outfile.open(set_file);
    if (infile.fail()) // error handling
    {
        cout << "error; raw_file cannot be open..\n";
    }
    while (!infile.fail())
    {
        char c = infile.get();
        if (c == '\n' || c == '/')
        {
            if (comp != "") 
            {
                input_comp.push_back(comp);
            }
            int num = input_comp.size();
            for (int j = 0; j < num; j++)
            {
                int idx = (num - 1) - j;
                outfile << "/" << input_comp[idx];
            }
            if (c == '\n')
            {
                outfile << "/" << endl;
            }
            input_comp.clear();
            str = "";
            comp = "";
        }
        else if (c == '.')
        {
            if (comp != "") 
            {
                input_comp.push_back(comp);
            }
            comp = "";
        }
        else 
        {
            str = c;
            comp = comp + str;
        }
    }
    infile.close();
    outfile.close();
    return 0;
}
This is inputs in 'raw_file' declared in code;
/blog.sina.com.cn/mouzhongshao
/blogs.yahoo.co.jp/junkii3/11821140.html
/allplayboys.imgur.com
This is result from Window; (This is what I want to get from above code)
/cn/com/sina/blog/mouzhongshao/
/jp/co/yahoo/blogs/junkii3/html/11821140/
/com/imgur/allplayboys/
This is result from Linux; (unexpected result)
/cn/com/sina/blog/mouzhongshao
/
/jp/co/yahoo/blogs/junkii3/html
/11821140/
/com
/imgur/allplayboys/
 
    