codedamn

How to create and run C++ files on playground

Asked by Rutwij Vaze about a year ago

2

New here!!, explain please...

1 Answer

    0

    Open a standard C/C++ project. H9Bsgup.th.png Call it whatever you want. Create it. Rename the main.c file to main.cpp.

    In the "main.cpp" file change:

    #include <stdio.h>
    
    int main() {
    
    printf("Hello World\n");
    
    return 0;
    
    }
    

    to:

    #include <iostream>
    
    using namespace std;
    
    int main() {
    
    cout<<"Hello World"<<endl;
    return 0;
    }
    

    In the ".cdmrc" file change:

    tabs: ['main.c']
    
    run-button: gcc main.c -o main.out && ./main.out
    

    to:

    tabs: ['main.cpp']
    
    run-button: g++ main.cpp -o output_file && ./output_file
    

    and then reload your project.

    It should print "Hello World" into the console.

    @codingcod

    Coding Cod

    @codingcod

Your answer