Parser written in PHP is 5.6x faster than the same C++ program in a similar test (g++ 4.8.5) I'm absolutely dumbfounded by this. I was trying to demonstrate to myself how much faster C++ is than even modern PHP. I ran a simple CSV parsing program in both that have the same output. The CSV file is 40,194,684 parsed down to 1,537,194 lines.
EDIT: This sparked alot more conversation than I had anticipated, here's the hardware stats for the machine both programs were run on, however its actually a VM running on a nutanix server:
CPU: Intel(R) Xeon(R) Silver 4215R CPU @ 3.20GHz
RAM: 16GB
PHP code (runtime 42.750 s):
&lt;?php
$i_fp = fopen(&quot;inFile.csv&quot;,&quot;r&quot;);
$o_fp = fopen(&quot;outFile.csv&quot;,&quot;w&quot;);

while(!feof($i_fp))
{
    $line = fgets($i_fp);
    $split = explode(';',$line);
    if($split[3] == 'E' || $split[3] == 'T')
    {
        fwrite($o_fp,join(',',[ $split[0], $split[1], $split[3], $split[4], $split[5], $split[6],
                                $split[10], $split[9],$split[11],$split[7],$split[32]]).&quot;\n&quot;);
    }
}
fclose($i_fp);
fclose($o_fp);

C++ code (runtime 3 m 59.074s) (compiled using g++ parse.cpp -o parse -O2 -std=c++1y)
#include &lt;fstream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;
#include &lt;vector&gt;

using std::string;
using std::vector;

vector&lt;string&gt; splitStr(string line, const char delimiter = ',')
{
    vector&lt;string&gt; splitLine;
    string buf;
    for(size_t i=0; i&lt;line.length(); i++)
    {
        if(line[i] == delimiter)
        {
            splitLine.push_back(buf);
            buf.clear();
        }else{
            buf += line[i];
        }
    }
    return splitLine;
}
string makeCSVLine(vector&lt;string&gt; splitLine)
{
    string line =
        splitLine[0] + ',' +
        splitLine[1] + ',' +
        splitLine[3] + ',' +
        splitLine[4] + ',' +
        splitLine[5] + ',' +
        splitLine[6] + ',' +
        splitLine[10] + ',' +
        splitLine[9] + ',' +
        splitLine[11] + ',' +
        splitLine[7] + ',' +
        splitLine[32] + '\n';
    return line;

}
int main(int argc, char* argv[])
{
    if(argc &lt; 3)
    {
        exit(EXIT_SUCCESS);
    }
    string inPath = argv[1];
    string outPath = argv[2];

    std::ifstream inFile;
    std::ofstream outFile;

    inFile.open(inPath.c_str());
    outFile.open(outPath.c_str());

    string line;
    while(std::getline(inFile,line))
    {
        vector&lt;string&gt; split = splitStr(line, ';');
        if(split[3][0] == 'E' || split[3][0] == 'T')
        {
            outFile &lt;&lt; makeCSVLine(split);
        }
    }
    inFile.close();
    outFile.close();
}

Both running on Red Hat Linux 8. I'm sure that it's some mistake I'm making in terms of C++ efficiency (possibly somewhere in how I'm using strings and vectors and whether they need to be re-sized repeatedly per loop), but I'm not sure what it could be. If anyone could help, shed some light. That would be great.
EDIT: Unfortunately, I cannot provide the input file as its a sensitive internal file.
Thanks to everyone for taking so much interest in this and all the advice provided. I've been extremely busy at work lately and unable to re-visit but look forward to doing so soon.
Always Profile Optimized Code.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rper-measure

Use -O3 optimisation: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Use a profiler: https://github.com/KDAB/hotspot

https://en.wikipedia.org/wiki/List_of_performance_analysis_tools


Reduce the duplication
string inPath = argv[1];
string outPath = argv[2];

std::ifstream inFile;
std::ofstream outFile;

inFile.open(inPath.c_str());
outFile.open(outPath.c_str());

to
std::ifstream inFile(argv[1]);
std::ofstream outFile(argv[2]);


Avoid string operations and allocations as much as possible. Prefer std::string_view if the string is only being read.

Remove string makeCSVLine(vector&lt;string&gt; splitLine) and use a formatter library like {fmt} https://github.com/fmtlib/fmt. Just to make the code prettier in
  outFile &lt;&lt; makeCSVLine(split);

, you're paying with a significant time penalty. OR use the good old (discussed below) fprintf if that turns out to be faster. If there is not a significant time gain, follow the guidelines and use fmt + streams.
 fmt::print(&lt;FILE*&gt;,
           &quot;{},{},{},{},{},{},{},{},{},{},{}\n&quot;,
           vec[0],
           vec[1],
           vec[3],
           vec[4],
           vec[5],
           vec[6],
           vec[10],
           vec[9],
           vec[11],
           vec[7],
           vec[32]);

Make it a macro or a lambda, or a function with inline attribute set if you want to use it with other answers but in a separate block of code.
See speed tests by fmt also. source file

vector&lt;string&gt; splitStr(string line, const char delimiter = ',')
Avoid returning the vector and pass it by reference to fill it inside the function ( return type will be void). This makes it Return Value Optimisation independent. All compilers will treat it the same way.
Also, consider using .reserve(), and/or .emplace_back() for the vector. reserve() has been tested to improve performance.

Use stringstream + getline with a delimiter. If you doubt that this is time costly, profile. Don't guess the performance results, measure them.
void split_by_delim(const string &amp;string, char delim, vector&lt;string&gt; &amp;r_out)
{
  std::stringstream ss(string);
  string word{};   // reserve space if you can guess it right.
  while (std::getline(ss, word, delim)) {
    if (!word.empty()) {
       r_out.push_back(word);
    }
  }
}


Avoid fstreams iff the reader or writer are the biggest time sinks. fprintf has been 40% faster in my tests with no loss in flexibility (I used it for writing ints and floats, it may vary(edit: yes it varied and the gain is insignificant compared to the other benefits of streams (or with fmt) ) with strings.).
Re comments that Stream IO is as fast as printf family IO, take it from Herb Sutter &amp; Bjarne Stroustrup:

It is often (and often correctly) pointed out that the printf() family has two advantages compared to iostreams: flexibility of formatting and performance. This has to be weighed against iostreams advantages of extensibility to handle user-defined types, resilient against security violations, implicit memory management, and locale handling.
If you need I/O performance, you can almost always do better than printf().

Emphasis mine.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rio-streams


In the current code, the reading speed (getline()) is bound by splitting the string and the write speed. In other words, more lines cannot be read as long as file writer has not done its job. You're not using the disk's read speed to the full potential here.
Consider splitting them such that all reading is done at once and data is stored in memory and it is written out at once.
If you want to keep peak memory usage to minimum, make use of threads and separate the reader and the (splitter + writer) in asynchronous threads.


Addendum
Machine: MacBook Air 2017, macOS Mojave, MQD32LL https://en.wikipedia.org/wiki/MacBook_Air#Technical_specifications_2
Profiler: Instruments.app.
Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Flags: -Ofast (and linking with {fmt} where required.)
PHP: 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )

Writer code to make CSV file, derived from Edward's answer for consistency: https://ideone.com/gkmUUN
Note that close enough timings should be considered the same due to fluctuations which can affect 3 to 5 seconds by a lot.
Matthew's code with the knowledge of line length and word length: 2.6s
Matthew's code as of rev 1 : 2.7s
Edward's algorithm with char array storage &amp; {fmt}: https://ideone.com/Kfkp90. This depends on the knowledge that the incoming CSV has a maximum line length of 300 characters and a maximum word length of 20 characters. 2.8s.
Martin's code as of rev 7: 2.8s
For less bug-prone code, and dealing with unknown length strings: https://ideone.com/siFp3A. This is Edward's algorithm which uses {fmt}. 4.1s.
gdate +%s.%3N &amp;&amp; php parser.php &amp;&amp; gdate +%s.%3N where parser.php is in Edward's code as of rev 5 : 4.4s
Edward's code as of rev 1: 4.75s
Edward's code with fprintf https://ideone.com/0Lmr5P : 4.8
OP's code with basic optimisations, and fprintf https://ideone.com/5ivw9R : 5.6s
OP's C++ code posted in the question: 6.2s
OP's C++ code with -O2: 6.4s
OP's C++ code with -O0: 45s