How to create and run C++ files on playground
Asked by Rutwij Vaze about 7 months ago
1
New here!!, explain please...
1 Answer
0
Open a standard C/C++ project.
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.
show more answers
Your answer