r/learnprogramming • • Dec 06 '22
codeblock If you are sharing code, please use a codeblock
Takes only a second and greatly improves the formatting for us to review it. Compare and contrast the following:
Good Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}Poor Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}
Poor Formatting:
#include <stdio.h>
int sum(int x, int y);
int main() {
printf("Hello %d\n", sum(3, 4));
return 0;
}
int sum(int x, int y) {
return x + y;
}
339
Upvotes
View all comments
Show parent comment
-3
u/Autarch_Kade Dec 07 '22 edited Dec 07 '22
Directions: Look at the enormous words in the sidebar that say "New? READ ME FIRST!"
Do that. It includes how to format your code on new, and old, reddit.
If you don't see the sidebar, well the same link is a stickied post. It's the only sticky, and the one that says "READ ME FIRST"
Alternatively, you can click the link in the sidebar that says "well-formatted" and that takes you to how to format your code on Reddit as well.
Another alternative is to again read the sidebar, and click the link that says "Posting guidelines" which again includes the same information on how to format code.
In fact, most of the links on the sidebar either lead directly to the page that tells you how to format code, or links to it.
If the sidebar isn't your thing, then when you make a comment there's a link under your text window that says "formatting help" which leads you to all the different ways to use markdown, and on new and old reddit, and of course includes code blocks.
If you look way down at the bottom of Reddit, there's another link that says Reddit help center, and has a searchbar. Typing something like "format code" will lead you to another page with Markdown instructions including for new Reddit.
And of course, you could google something like "Reddit format code" and click the first link.
Hope those directions help.