Home | News | Documentation | Download

Posting code? Read this first!


#1

This is more addressed to the newer people of this forum, but I think it would be a good refresher for some.

USE CODE TAGS!!!

What is so special about these things?
For one, they help show where you code begins and ends. Plus it doesn’t mess with your spacing or indents (a typical aesthetic in programming).

Why do you care so much?
When people are communicating code and there is no indentation and lousy spacing, code is super-hard to read.

How do I use code tags?
The code tag is simple, it is ```. So to begin a code tag, type the following: ``` . Then type all your code or copy and paste, whatever you want. When you are done, use the closing tag which is the same than previously used: ``` .

For example :

```
int main(int argc, char **argv)
{
TApplication *myApp = new TApplication(“myApp”, &argc, argv);
TH1F *h1f = new TH1F(“h1f”,“Test random numbers”, 200, 0, 10);
h1f->SetFillColor(45);
h1f->FillRandom(“sqroot”, 10000);
h1f->Draw();
myApp->Run();
return 0;
}
```

Will display like this:

int main(int argc, char **argv)
{
   TApplication *myApp = new TApplication("myApp", &argc, argv);
   TH1F *h1f = new TH1F("h1f","Test random numbers", 200, 0, 10);
   h1f->SetFillColor(45);
   h1f->FillRandom("sqroot", 10000);
   h1f->Draw();
   myApp->Run();
   return 0;
}

See the difference? :wink:


Histograms in loop
Root very poor in layout of TGLabels Neet Help
Unable to compile root programs outside root environment
Compiled macro can't be executed
Writing data from one root file to another
Tips for Efficient and Successful Posting
Root on windows (Visual studio 2010)
#2

#3

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.