Turbo C / Turbo C++ Online Compiler

Turbo C / Turbo C++ Online Compiler

Write and run your Turbo C or Turbo C++ style programs in the browser, with nothing to install. Press Run and the program is compiled with a modern GCC compiler.

Please note: this is not the original Turbo C. Turbo C and Turbo C++ were Borland compilers for DOS from the 1990s. This page runs standard C on GCC, so a few old Turbo C features need a small change before a program will build. The table below shows each one.

Turbo C code that needs changing on GCC

Turbo C codeWhat happens on GCCWhat to do
#include <conio.h>Build fails: the header does not exist.Delete the line and remove anything that needs it.
clrscr()Not available.Delete the call. The output panel starts empty on every run.
getch() / getche()Not available.Delete a final getch() that only keeps the window open. To read a character, use getchar() (supply the character in Stdin before Run).
void main()Builds with a warning.Write int main(void) and end with return 0;.
gets(str)Removed from the C11 standard.Use fgets(str, sizeof str, stdin).
gotoxy(), textcolor(), cprintf()Not available.Print with printf() instead. There is no standard C version of these.
graphics.h, initgraph()Not available.BGI graphics does not exist on GCC. Rewrite the output as text.
int is 16 bitsint is 32 bits (4 bytes).Use a type large enough for the values. Signed integer overflow is undefined behavior in standard C.
#include <iostream.h> (Turbo C++)Build fails.Use #include <iostream> and using namespace std;, and run it on the C++ compiler.

Example: a Turbo C program, fixed for GCC

Before (Turbo C):

#include <stdio.h>
#include <conio.h>

void main() {
    int a, b;
    clrscr();
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);
    printf("Sum = %d", a + b);
    getch();
}

After (runs on GCC):

#include <stdio.h>

int main(void) {
    int a, b;
    printf("Enter two numbers: ");
    scanf("%d %d", &a, &b);
    printf("Sum = %d\n", a + b);
    return 0;
}

Learn more

Read Turbo C vs Modern C for the full history. For error messages, see the implicit declaration guide. To practise, try the C program examples and C exercises, or open the full C IDE.

Turbo C online compiler FAQ

Is this the real Turbo C?

No. It is a modern GCC compiler running in your browser. Turbo C was a DOS program, and this page does not emulate DOS.

Why does conio.h give an error?

conio.h is a Borland header that GCC does not include. Remove the include, and remove calls such as clrscr() and getch() that came from it.

What can I use instead of getch()?

Usually nothing. Programs add getch() at the end to keep the DOS window open, and the output stays visible here. To read a character, use getchar().

Can I use graphics.h here?

No. The BGI graphics library is not part of GCC, so graphics programs must be rewritten to print text.

Why does my program give a different result than in Turbo C?

In Turbo C an int is 16 bits, and on GCC it is 32 bits. Use a type large enough for the values. Signed integer overflow is undefined behavior in standard C.

Do I need DOSBox?

No. Standard C programs run directly in your browser here.