Posting code? Read this first!

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:

8 Likes

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