<< !! Posting Code? Read this First !! >>

This is a discussion on << !! Posting Code? Read this First !! >> within the C Programming forums, part of the General Programming Boards category; /* NOTE FROM MOD: This thread was origanally titled: !! <> Everybody Please Read <> !! *\ This is more ...

  1. #1
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230

    Exclamation !! <> 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: [/code] .


    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
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    ahhh... it is a beautiful thing. ***wipes tear from eye***
    Blue

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 05-29-2008, 11:36 AM
  2. Overloading << and >>
    By MMu in forum C++ Programming
    Replies: 1
    Last Post: 04-21-2008, 06:49 AM
  3. The >> and << thingies..
    By eviscerator in forum C++ Programming
    Replies: 8
    Last Post: 08-06-2004, 10:50 AM
  4. << and >> overloading
    By Armatura in forum C++ Programming
    Replies: 2
    Last Post: 12-07-2003, 05:19 PM
  5. please read this source code and tell me what is wrong
    By goof in forum Windows Programming
    Replies: 7
    Last Post: 12-01-2001, 10:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21