Thread: Everybody Please Read

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    26

    Everybody Please Read

    !! <> Everybody Please Read <> !!
    /* NOTE FROM MOD: This thread was origanally titled: !! <> Everybody Please Read <> !! *\

    This is more addressed to the newer people of this forum, but I think it would be a good refresher for some.

    USE CODE TAGS!!!

    What are code tags?
    They are HTML-Like tags that you can insert into your post and create a specially formatted box for source code.

    What are so special about these things?
    For one, they help show where you code begins and ends. Plus it doesn't mess with your spacing or indents (a typical aesthetic in programming).

    Why do you care so much?
    I love talking on these forums and giving and receiving help. However, when people are communicating code and there is no indentation and lousy spacing, code is super-hard to read.

    How do I use code tags?
    Well if you have any experience with HTML it is fairly simple to use. A tag has a beginning and ending. A beginning tag looks like this: [tag] and an ending tag looks like this: [/tag] . The tag name for the code tag is simple, it is "code". So to begin a code tag, type the following:
    Code:
     . Then type all your code or copy and paste, whatever you want. When you are done, use the closing tag which uses the same tag name but with a forward slash to denote a closed tag:
    .


    Example of nicely formatted code (with code tags):


    code:--------------------------------------------------------------------------------
    int Stuff::save(Stuff *sPtr)
    {
    ofstream outfile("Outfile.txt");

    if( !outfile )
    {
    cerr << "Couldn't open file" << endl;
    return 1;
    }

    outfile << sPtr->string << endl << sPtr->stringTwo << endl << sPtr->num << endl;

    outfile.close(); // I don't trust destructors

    return 0;
    }

    int main()
    {
    Stuff stuffObject;

    strcpy(stuffObject.string, "Hello");
    strcpy(stuffObject.stringTwo, "Yo");
    stuffObject.num = 10;

    stuffObject.save(&stuffObject);

    return 0;
    }
    --------------------------------------------------------------------------------


    An example of dirty, ugly code (without code tags):
    int Stuff::save(Stuff *sPtr)
    {
    ofstream outfile("Outfile.txt");

    if( !outfile )
    {
    cerr << "Couldn't open file" << endl;
    return 1;
    }

    outfile << sPtr->string << endl
    << sPtr->stringTwo << endl
    << sPtr->num << endl;

    outfile.close(); // I don't trust destructors

    return 0;
    }

    int main()
    {
    Stuff stuffObject;

    strcpy(stuffObject.string, "Hello");
    strcpy(stuffObject.stringTwo, "Yo");
    stuffObject.num = 10;

    stuffObject.save(&stuffObject);

    return 0;
    }


    See the difference?

    Sorry, I had to get this off my chest

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Eh? This post is at the top of the page, so why repost it?
    Example of nicely formatted code (with code tags):
    Nope, no code tags there...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Closed. If you're having problems, PM me or another mod for help.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. read Causes Freezing?
    By Masna in forum C Programming
    Replies: 5
    Last Post: 07-18-2008, 04:31 PM
  2. Read() problems
    By yay4rei in forum C Programming
    Replies: 2
    Last Post: 07-21-2005, 10:47 AM
  3. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  4. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  5. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM