C++ Simple IDE version 1.0.0

· · 休闲·娱乐

C++ Simple IDE version 1.0.0

The author of this code is EthanSong. All rights reserved(2023).

This code is a opensource code. The source is below.

#include <string>
#include <iostream>
#include <io.h>
using namespace std;
#define STDOUT 1
int main()
{
    printf("Welcome to C++ simple IDE version 1.0.0.\n");
    printf("The author of this code is EthanSong. All rights reserved(2023).\n");
    printf("Please enter the route you want your file to save.\nNote: The route's seperate char must be / not \\.\n");
    string filename;
    getline(cin, filename);
    printf("Please enter the filename you want your file to be.\nNote: The filname must be in English and with no spaces.\n");
    string name;
    getline(cin, name);
    if (filename[filename.size() - 1] != '/')
    {
        filename += '/';
    }
    filename += name;
    string a = filename;
    filename += ".cpp";
    a += ".exe";
    int oldstdout = dup(STDOUT);
    FILE *f = freopen(filename.c_str(), "w", stdout);
    while (getline(cin, name) && name != "[exit]")
    {
        cout << name << endl;
    }
    fclose(f);
    freopen("CON", "w", stdout);
    dup2(oldstdout, STDOUT); 
    name = "g++ ";
    name += filename;
    name += " -o ";
    name += a;
    system(name.c_str());
    system(a.c_str());
    system("pause");
    return 0;
}