I had to generate txt file with some numbers to feed to another program and this is what I made in Python:
import os
os.chdir("C:\\Users\\User\\Desktop")
if __name__ == "__main__":
    file = open("testpython.txt", "w")
    file.write("0=x 41945088 768 \n")
    d = 41945984;
    v = 896;
    offset = 1280;
    for i in range(v, 3500000000, 1408):
        file.write("".join(str(i)+"=x ")+str(d)+" "+str(offset)+"\n")
        d = d + offset + 128
    file.close()
and same in C++:
#include <fstream>
int main() {
    std::ofstream myfile;
    myfile.open("C:\\Users\\User\\Desktop\\testcpp.txt", std::ios::app);
    myfile << "0=x 41945088 768" << "\n";
    unsigned long long int d = 41945984;
    int v = 896;
    int offset = 1280;
    for (unsigned long long int i = v; i <= 3500000000; i+=offset+128) {
        
        myfile << i << "=x " << d << " " << offset << "\n";
        d = d + offset + 128;
        
    }
    
    myfile.close();
    return 0;
}
What is wrong with C++ code that it runs so long (~26s vs ~5s for Python)? I think it's quite simple and standard way of writing to file with C++? Please notice in the for loop it will be much larger number than 350000000 (I set it like that just for testing), that's why there is unsigned long long int.
 
    