Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Standards...or just ettiquette

Gregry2Gregry2 Posts: 607Member
Are these things

[code]
void main(){}/*declaration of main as void*/

int foo();/*without void in args*/

void a(){
printf("hi...");
}/* no return statement*/

int main(){
void* a=malloc(40);/*(I'd personally never do this
not freed, even though end of program is right here*/
}
[/code]

really bad? For the last, how about some heap nodes held by static pointers needed for the whole program? Do i have to call a freeing function at the end of a program?

Thats all.
{2}rIng

to TokoG:
I'm actually a high school student :) If you look at my page, I'm only 15...

The classes are the usual...English, History/Geography, some math (Geometry, probably my favorite subject), a science class (sadly Biology, I'd rather have chemistry...), and a pathetic class for Computer...jk, its only Graphics, no fun stuff

My Electives are Video Editing and Band...should have taken Biochemistry...half chemistry at least...oh well...Band was better.

Thats enough about me. Sorry


Comments

  • bilderbikkelbilderbikkel Posts: 754Member
    'The best thing of coding standards is
    that there are so many to choose from'
    (cited from many)

    If you read
    [b]Herb Sutter,Andrei Alexandrescu. C++ coding standards:
    101 rules, guidelines, and best practices. ISBN: 0-32-111358-6[/b]
    or the C++ FAQ LITE (http://www.parashift.com/c++-faq-lite/),
    you would have the following comments on your code:

    : [code]
    : void main(){}/*declaration of main as void*/
    //Bad style. main is of type int, although many compilers support this.

    : int foo();/*without void in args*/
    //Great style! (void) is called an 'abomination' by many,
    //of which amonng is Bjarne Stroustrup

    : void a(){
    : printf("hi...");
    : }/* no return statement*/
    //Great style! void requires no return statement at the end.
    //In the beginning and middle, return can be useful.

    : int main(){
    : void* a=malloc(40);/*(I'd personally never do this
    : not freed, even though end of program is right here*/
    : }
    //Bad style! Always free your memory. For C++ programmers it is
    //recommended to use new and delete over malloc and free. Also,
    //for C++ programmers it is even recommended to let objects manage
    //resources (like e.g. the std::auto_ptr (see e.g.
    //www.codepedia.com/1/CppAutoPtr))
    [/code]

    See ya,
    bilderbikkel

Sign In or Register to comment.