Skip to main content

CPPinator is a Python automation script designed for compiling and running multiple C++ files in a specified directory. It simplifies the process of handling multiple C++ programs and provides a clear and organized output for each program's execution along with the execution time for each program.

Project description

CPPinator

CPPinator is a Python automation script designed for compiling and running multiple C++ files in a specified directory. It simplifies the process of handling multiple C++ programs and provides a clear and organized output for each program's execution along with the execution time for each program.

How it works

  1. The script allows you to specify a directory path where your C++ source code files are located.

  2. It changes the current working directory to the specified path.

  3. CPPinator lists all the C++ source code files with the .cpp extension in the directory.

  4. For each .cpp file found, it compiles the code using g++ and runs the resulting executable.

  5. The script captures and displays the output and any errors produced by each program.

  6. Upon successful execution of all C++ files, it provides a summary message.

  7. Finally, the compiled executable file (a.exe) is deleted to keep your directory clean.

Usage

  1. Ensure you have Python and a C++ compiler (e.g., g++) installed on your system.

  2. Install the CPPinator package from PyPI using pip:

    pip install CPPinator
    

    OR

    Clone or download the CPPinator.py script to your local machine.

    git clone https://github.com/Hardvan/CPPinator
    cd CPPinator
    pip install .
    
  3. Call the compile_and_run_cpp_files function from the CPPinator package with the directory path as an argument.

    from CPPinator import compile_and_run_cpp_files
    
    compile_and_run_cpp_files("path/to/your/directory")
    

    View the run.py file in the example directory for a working example.

Example Output

Here's an example of the script's output when run with a list of C++ files in the Basic Problems directory.

Changing working directory... Current working directory: F:\CPPinator\Basic Problems

List of .cpp files:

  1. count_digits.cpp
  2. divisors.cpp
  3. gcd.cpp
  4. palindrome_number.cpp
  5. prime.cpp
  6. reverse_array.cpp
  7. reverse_number.cpp

Running .cpp files:

  1. count_digits.cpp (1.07s)

    No. of digits in 123456789 is:
    9
    9
    9
    Expected: 9

  2. divisors.cpp (1.14s)

    Divisors of 100 are:
    1 100 2 50 4 25 5 20 10
    Divisors of 100 are:
    1 2 4 5 10 20 25 50 100
    Expected: 1 2 4 5 10 20 25 50 100

  3. gcd.cpp (1.16s)

    GCD of 12 and 15 is:
    3
    3
    Expected: 3

  4. palindrome_number.cpp (1.07s)

    12321 is palindrome: true
    Expected: true

  5. prime.cpp (1.11s)

    100 is not prime
    100 is not prime
    Expected: not prime

  6. reverse_array.cpp (1.05s)

    Original array:
    1 2 3 4 5
    Reversed array using two pointers:
    5 4 3 2 1
    Reversed array using recursion:
    5 4 3 2 1
    Reversed array using temporary array:
    5 4 3 2 1
    Expected: 5 4 3 2 1

  7. reverse_number.cpp (1.24s)

    Reverse of 123456789 is: 987654321
    Expected: 987654321

✅ Ran all C++ files successfully. (7.84s)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CPPinator-1.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

CPPinator-1.0.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file CPPinator-1.0.3.tar.gz.

File metadata

  • Download URL: CPPinator-1.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.4

File hashes

Hashes for CPPinator-1.0.3.tar.gz
Algorithm Hash digest
SHA256 c0625e106fe0d4ab700da024d751e0e4a37559b108a328505f91041e4e9c6fab
MD5 0478fe74347006023a44ce75161ecdc1
BLAKE2b-256 9820f524038bed5f84d191528c07f8a09dda3b5ca9ae1d4ebe267bca10a72710

See more details on using hashes here.

File details

Details for the file CPPinator-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: CPPinator-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.4

File hashes

Hashes for CPPinator-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30e06cf9658cc37a1aacc2fa0b7f1eb6bc59671790104a2583d36ab6ee5fb886
MD5 85d1c2d9194dfcf9b3ec88cd343a5689
BLAKE2b-256 aadd852e60d436c4a1160bd8319172b4f19c6675fc176fcc1a32ad3fe6386374

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page