Codectionary / Developer documentation / C++

Learn what the C++ editor and optional remote runner actually do, what they cannot promise, and when to use a local compiler.

Check availability before relying on Run

The Playground lets you create or select a .cpp file, edit it with C++ syntax highlighting and save or copy your code. Its Language support panel currently labels Java and C++ “Not enabled”. There is a server-side execution path in the application, but it works only if the site operator configures an external Judge0-compatible service and a C++ language ID. The public interface does not guarantee that service is enabled. If Run reports “Java and C++ execution is not configured yet” or that execution is unavailable, use a local compiler instead.

This is not the browser’s HTML/JavaScript preview. Browser JavaScript does not compile your C++ file. The C++ request sends source and optional input to Codectionary’s /api/execute endpoint, which can submit a single source file to the configured remote provider. Do not put credentials or personal data into code sent to a remote runner.

Create and run one complete source file

Open the Codectionary Playground and choose C++ from New File, or open a C++ article example in the Playground. Select the .cpp tab before pressing Run: the runner submits only the selected file. Paste a complete program with one main function. The example reads one whole number. Put a value such as 7 in the Program input field, then press Run. If remote execution is configured and succeeds, the output panel shows Double: 14.

A project may contain several visible tabs, but the remote C++ submission does not combine them. Header files and other .cpp files in the editor are not sent with the selected file. For a multi-file project, use a local toolchain and build system.

One-file C++ input example

#include <iostream>

int main() {
  int number{};
  if (std::cin >> number) {
    std::cout << "Double: " << number * 2 << '\n';
  } else {
    std::cerr << "Enter a whole number.\n";
    return 1;
  }
}

Read output and diagnostics

The bottom output panel displays a status followed by any compile output, standard output and standard error returned by the provider. A syntax error should appear as a compilation failure with diagnostics; a running program can instead report an execution failure or time limit. The page also shows connection and usage-limit errors when the runner cannot accept a job. These are different from C++ compiler errors.

For the example, the Program input box supplies text to standard input; std::cin parses the number. If input is absent or not a whole number, the program writes its own message to standard error and exits with a nonzero result. This is a submitted input string, not an interactive terminal that pauses to ask you questions after the run has begun.

Know what is and is not verified

The backend is written to submit to a configured Judge0-compatible provider. The provider’s C++ language ID decides the actual compiler and version; Codectionary does not pin a public compiler name or C++ language standard in this request. You cannot rely on a specific modern standard mode in the Playground. For C++17-or-newer exercises, use a local compiler with an explicit standard flag until the deployed provider and its language list are verified.

The application requests a two-second CPU limit plus a short allowance, a five-second wall limit, about 256 MB of memory, a 64 MB stack, a 1,024 KB file-size limit and disabled networking. It also caps source at 32 KB, input at 4 KB and displayed output fields at 16,000 characters. Provider enforcement can vary, so these are requested limits rather than guarantees about the remote sandbox. The runner does not offer installed project libraries, multiple source files, a persistent filesystem or a web server. Standard-library availability follows the configured compiler; third-party library availability is not promised.

When to switch to local development

Use a local compiler for dependable builds, deliberate standard selection, multi-file projects, external libraries, debugging, and programs that need files or network access. Follow the installation guide for your operating system, save the source as main.cpp and compile it with a selected standard. The Playground remains useful for editing and sharing small examples even when remote execution is unavailable.

Do not infer that a C++ program works merely because the HTML preview updates. Select the C++ file and read its run result, or build and execute it locally. The documentation examples show C++ syntax; whether their Run action succeeds depends on the deployed execution service.

Syntax

#include <iostream>

int main() {
  int number{};
  if (std::cin >> number) {
    std::cout << "Double: " << number * 2 << '\n';
  } else {
    std::cerr << "Enter a whole number.\n";
    return 1;
  }
}

Examples

Read one number from standard input

A complete single-file program for a configured runner or a local C++ compiler.

#include <iostream>

int main() {
  int number{};
  if (std::cin >> number) {
    std::cout << "Double: " << number * 2 << '\n';
  } else {
    std::cerr << "Enter a whole number.\n";
    return 1;
  }
}
  1. Enter 7 as Program input before running. std::cin reads from the submitted standard-input text.
  2. If extraction succeeds, the program multiplies the value by two and prints Double: 14 to standard output.
  3. If no valid whole number is supplied, it writes an error to standard error and returns 1. This lets you compare normal output with a program-reported failure.
  4. The example uses only the standard library and a single source file. A configured remote C++ service is required to execute it in the Playground; it can also be compiled locally.

Best practices

  • Check the Language support panel and treat runner availability as configuration-dependent.
  • Select the C++ file before pressing Run; other editor tabs are not included.
  • Never submit secrets or personal data to a remote code runner.
  • Use a local compiler when you need a verified compiler version, language mode or multi-file build.

Runtime & versions

Compiled native applications. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

ISO C++ resources

Specifications & further reading