// Segmentation fault example
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

int main ()
{
    const char file1[]= "C:/temp/seven_words.txt";
    const char file2[]= "C:/temp/file2.txt";
    char temp[20];

    ifstream fin (file1);
    if (!fin)
    {
        cerr << "Unable to open file " << file1 << endl;
        exit(1);
    }

    // read 7 records
    for (int i = 0; i < 7; i++)
    {
        fin >> temp;
    }
    fin.close();

    // open second file
    fin.open(file2);
    if (!fin)
    {
        cerr << "Unable to open file " << file2 << endl;
        exit(1);
    }
    cout << "Program completed successfully" << endl;
}

***** Code::Blocks PC Output *****

Unable to open file h

***** Microsoft Visual Studio 2015 Output *****

Program completed successfully



***** Linux (2 different) with g++ compiler (2 different) Output *****

Program completed successfully

***** MacBook (Xcode, Code::Blocks, gnu compiler) *****

Program completed successfully

seven_words.txt file

abnormal
cinch
dictate
awful
bloodstain
electroencephalograph
servomechanism