# Web-based C tools

(compiler-explorer)=
## Compiler explorer
:::{dropdown} Details
The following editor could be useful if you have problems with your local installation or would like to test something. 

For full-screen, use [compiler-explorer.com](https://compiler-explorer.com). To have the same layout when you use the site for the first time:
1. When you arrive, you should see a C++ source on the left and a gcc compiler assembler output on the right.
1. On the left tab (editor) – change the language from `C++` to `C`.
1. Close the right tab completely.
1. Click on ➕ `Add new...` on the editor under the `C source #1`. A menu with `Compiler`, `Execution Only`, etc should pop up.
1. Click on `Execution Only`. A new tab `Executor ...` will be opened.
1. Move one tab in such a way that you have one tab on the left and one on the right.
1. On the `Executor` tab, change the compiler to `x86-64 clang (trunk)`.

You will get an error with the default code, because a C program requires the `main` function to be compiled as an executable.

You can save/load your code locally using 💾 `Save/Load`

The following frame may set cookies in your browser and the code you write is sent to Compiler Explorer's servers for hashing and/or compilation and/or running. Refer to their [cookie](https://godbolt.org/#cookies) and [privacy policy](https://godbolt.org/#privacy).
:::

<iframe width="800px" height="600px" src="https://compiler-explorer.com/e#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,paneName:playground,selection:(endColumn:2,endLineNumber:15,positionColumn:2,positionLineNumber:15,selectionStartColumn:2,selectionStartLineNumber:15,startColumn:2,startLineNumber:15),source:'%23include+%3Cstdio.h%3E%0A%23include+%3Cstdlib.h%3E%0A%23include+%3Ctime.h%3E%0Aint+main()+%7B%0A++int+total+%3D+1000000,+inside+%3D+0%3B%0A++srand(time(0))%3B%0A++for+(int+i+%3D+0%3B+i+%3C+total%3B+i%2B%2B)+%7B%0A++++double+x+%3D+(double)rand()+/+RAND_MAX%3B%0A++++double+y+%3D+(double)rand()+/+RAND_MAX%3B%0A++++if+(x+*+x+%2B+y+*+y+%3C%3D+1)%0A++++++inside%2B%2B%3B%0A++%7D%0A++double+pi+%3D+4.0+*+inside+/+total%3B%0A++printf(%22Estimated+pi:+%25f%5Cn%22,+pi)%3B%0A%7D'),l:'5',n:'0',o:playground,t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:executor,i:(argsPanelShown:'1',compilationPanelShown:'1',compiler:cclang_trunk,compilerName:'',compilerOutShown:'0',execArgs:'',execStdin:'',fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'',overrides:!(),runtimeTools:!(),source:1,stdinPanelShown:'1',wrap:'1'),l:'5',n:'0',o:'Executor+x86-64+clang+(trunk)+(C,+Editor+%231)',t:'0')),header:(),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4"></iframe>

## OnlineGDB

<https://www.onlinegdb.com> has debugging capability compared to [Compiler Explorer](compiler-explorer), but does not support the latest C standard. 
