If you post code on this forum, put your code in code tags.
If you already pasted some code without using code tags, go back and edit your post and put code tags in!
It's very hard to read code that isn't in code tags! Help us help you by making your code easier to read and follow!
It's very simple:
[code]
paste your code here
[/code]
This:
int main()
{
int myvar = 15;
cout << myvar;
return 0;
}
Becomes this:
1 2 3 4 5 6
int main()
{
int myvar = 15;
cout << myvar;
return 0;
}
Much nicer, isn't it?
Notice the added benefit of line numbers so we can easily point out which line of code has the problem in it.
-----------------------------------------
I created this article because I find myself telling many people to use code tags a lot. Sometimes I find myself telling it to the same person multiple times. With an article here now I can just link them to this.
Using code tags alone isn't enough. Most programs are more complex than the example that was presented. You have to beautify the code in your code editor first. The code tags will not indent for you. It is also better to avoid using tabs. Use 3 or 4 spaces in place of tabs. Inconsistent tabbing causes all kinds of problems. It doesn't do much good to put the code within tags if it is difficult to understand the nested programming structures and loops.
I created this article because I find myself telling many people to use code tags a lot. Sometimes I find myself telling it to the same person multiple times. With an article here now I can just link them to this.
This is an article subject that has been that has been posted about on a few occasions:
http://www.cplusplus.com/forum/articles/9044/#msg41810
http://www.cplusplus.com/forum/articles/1624/#msg5695
Unfortunately, they don't get read and you have to either tell people how to put code in tags or point them to one of the posts about it.