c program runner

#include <iostream>
#include <cstdlib>
#include <cstring>

int main(int argc, char* argv[]) {
    if (argc < 2) {
        std::cerr << "Usage: " << argv[0] << " <C_program_file>" << std::endl;
        return EXIT_FAILURE;
    }

    FILE* file = fopen(argv[1], "r");
    if (!file) {
        std::cerr << "Error opening file: " << argv[1] << std::endl;
        return EXIT_FAILURE;
    }

    fseek(file, 0, SEEK_END);
    long length = ftell(file);
    fseek(file, 0, SEEK_SET);

    char* buffer = new char[length + 1];
    std::memset(buffer, 0, length + 1);

    if (fread(buffer, 1, length, file) != static_cast<size_t>(length)) {
        std::cerr << "Error reading file: " << argv[1] << std::endl;
        delete[] buffer;
        fclose(file);
        return EXIT_FAILURE;
    }

    fclose(file);

    // Compilation and execution steps are not included.
    // You would typically use a compiler and execute the compiled program here.

    delete[] buffer;

    return EXIT_SUCCESS;
}