Tutorial :About stackoverflow comment



Question:

This might appear silly, but I have been wondering for a while, how can I put code inside a comment in stackoverflow. I haven't been able to figure this out. I have seen users putting those grayish blocks in a comment.

I tried (<pre><code>) but that didn't work.

Regards


Solution:1

You can use backquotes to insert code in comments, just as you might insert inline code in a question or answer: printf("here is some code\n");


Solution:2

use backticks "" <code here> "".

BTW, this belongs on meta.


Solution:3

Putting four spaces before the code will automatically generate the code block. Inside of a comment, you can wrap it with ` and it will demarcate the code. Or simply mark up the code that you want to be laid out as code and press the button with the 101010 label.


Solution:4

You can't, because the comments only support limited markdown tags.

Stop with the down votes - this was migrated while i was in the middle of editing it!! What i was busy clarifying is that it isn't a full code block - you don't get syntax coloring etc, just the highlighted background.

For the FAQ on comments check here. For the details on allowed markdown, check here.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »