Standards...or just ettiquette

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

  • '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.

Howdy, Stranger!

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

Categories

In this Discussion