As explained in the editing help, in MarkDown you can achieve preformatted text by using four spaces indentation.
To achieve this after typing (or copy pasting) the code, simply select the relevant part and the click on the code button in the editor (between blockquote and insert image) or press Ctrl+K.
To test this I have taken an example of for cycle in C from this website. (Basically a random site that I got after searching for "for cycle c example".)
#include <stdio.h>
int main()
{
int i;
for (i=1; i<=3; i++)
{
printf("%d\n", i);
}
return 0;
}
You can find much more detailed information in the FAQ post: How do I format my code blocks? Here is a screenshot which I copied from that post:
Since you explicitly mentioned <code>
, the FAQ post says about this possibility: "Embed within <code>
tags, and manually encode HTML entities: `` <html>
`"
So if you prefer this for some reason this solution, it is also possible, although with some additional work. (In the above excerpt I had to use #
for #, <
for < and >
for >.)
#include <stdio.h>
int main()
{
int i;
for (i=1; i<=3; i++)
{
printf("%d\n", i);
}
return 0;
}