IMPORTANT - READ BEFORE POSTING

UPDATED

Hi everyone!

This post is basically a sticky that everyone should read prior to posting in order to acquaint themselves with rules and features of this subreddit. Since it's quite obvious that many of our new posters have trouble with code formatting, in turn making life difficult for those of us who want to help; the first item in this sticky will be a short tutorial on proper code formatting. If need be, we'll hide posts that haven't formatted their code correctly until OP fixes the post in question.

By the way, this can be a discussion thread as well, so feel free to post your opinions and suggestions. Also, we'll keep adding new items as they come up.


###ITEM 1 - FLAIRS


We've introduced link flairs, as well as u/AutoModerator!

So far, we have two link flairs - OPEN and SOLVED. You, as regular subscribers should have access only to the SOLVED flair, since u/AutoModerator will automatically flair every new post as OPEN.

In addition, we've added links in the sidebar to allow you to search by flair.

Of course, we would be very appreciative if you marked your post as SOLVED if someone actually helps you solve your problem.

Thanks to u/ftbmynameis for the great idea!

These are the steps you need to take in order to flair up your post:

  1. Click on the flair button on your post.
  2. Select OPEN or SOLVED from the pop-up menu.
  3. Save

###ITEM 2 - CODE FORMATTING


If you want to post a snipper of code, and do it by simply pasting it into the text box here on reddit, in the vast majority of cases, it will not be formatted correctly, as the code needs to be preceded by four whitespace (spaces) characters. So here's a neat little trick to do this, which requires the least hassle.

Say you have a little snipper of code in your favourite text editor, like this: http://i.imgur.com/fJzIQiD.png.

  1. Select the desired snippet of code and you should have something that looks like this: http://i.imgur.com/08F5Tdu.png
  2. Now that your code is selected, press TAB once to indent it and end up with this: http://i.imgur.com/aYwnbXf.png
  3. You'll notice that the indentation on the first line is not selected; this is bad. Select the desired snippet of code again, but taking care to select all the empty space that's been indented as well, and you should have something like this: http://i.imgur.com/h2hKibm.png

Now, all you have to do is copy and paste this code into a text box here on reddit, and you should end up with pretty and legible code like this:

#include <iostream>

int main() {
    std::cout << "Hello World!" << std::endl;
}

Please learn to properly format your code, or else...


###ITEM 3 - INLINE CODE


Short one - if you want to type out one line of code that is properly formatted, say std::vector, you can put it in those weird single quotes that I don't know the proper term for - ` - it's located on the tilde (~) key, and laugh as you might at the triviality, it took me longer than I'd care to admit to figure this out.

Example: `std::vector` yields std::vector

Digression - this is the same way code formatting works on Stackoverflow.


###ITEM 4 - SPOILER TAG


Just a quick addition - spoiler tags. If for some reason you want to mark a portion of text or code as a spoiler, thus hiding it until a user hovers over said code, you can use the spoiler tag.

The general format of a spoiler tag is as follows - [Spoiler content here](/spoiler). For example:

  • Say I want to hide "Hello world!", I would do it like this: [Hello world!](/spoiler) and get this: Hello world!
  • If I want to hide a line of code, say, std::cout << "Hello world!" << std::endl;, I would do it like this:
  • [`std::cout << "Hello world!" << std::endl;`](/spoiler) and get this: std::cout << "Hello world!" << std::endl;

###ITEM 5 - HOMEWORK QUESTIONS


We get many questions along the lines of "can you do my homework for me". While we are happy to answer specific questions - for example "I expected this code to work, but it doesn't why?" or "what does this error message mean?" or even (if you're lucky) "I wrote this for my homework, can you give me a code review?".

However, please do not ask us to write any code in a homework question. There are several reasons for this:

  1. It defeats the point of setting you homework, which is to get you to write your own code.
  2. Professors can usually tell.
  3. It may count as plagiarism under your University's rules. (And there are professors out there savvy enough to check.)
  4. If you are able to get an assignment in without understanding the principles behind it you will have difficulty with other principles that are build on top of it, and the problem will snowball.

If you are totally lost with your problem, and can't figure out how to ask the question, a good start is to break the problem down into smaller problems. For example: "how do I read this file into this struct?" can become "how do I read a file?" and "how do I make this struct?". The smaller you can make the problem, the easier it is for you and us to handle.


Posted Feb 29, 2016, 11:02 PM UTC

105
Loading comments…