What's your prefered program layout?

This is a discussion on What's your prefered program layout? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Looks cool, except: > Versions of GRASP for Java, Windows, Linux, and various Unix Systems are available Do they think ...

  1. #31
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Looks cool, except:

    > Versions of GRASP for Java, Windows, Linux, and various Unix Systems are available

    Do they think Java's an OS?

  2. #32
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    Originally posted by Govtcheez
    Looks cool, except:

    > Versions of GRASP for Java, Windows, Linux, and various Unix Systems are available

    Do they think Java's an OS?
    Java is an OS, isn't it?

  3. #33
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    Originally posted by Brian


    Java is an OS, isn't it?
    PLEASE tell me you are kidding... PLEASE!!?!?!?

  4. #34
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    JavaOS

  5. #35
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    no crap....

    http://www.sun.com/smi/Press/sunflas...529.11819.html

    Never heard of it before..

  6. #36
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    See the post called Operating Systems.

  7. #37
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    [CODE]
    int main () {
    //whatever
    return 0;
    }
    CODE]
    The problem there is if you have many loops inside each other, if you have four opening brackets before the first closing bracket then things can get quite confusing.

    for(loop)
    {
    for(loop)
    {
    //Do this
    if(I die)
    {
    //do I goto heaven or hell?
    {
    //I goto heaven
    }
    else
    {
    cout<<"Sucked in pal!"
    }
    }
    //Am I wounded?
    {
    //Scream out for mummy (Australian spelling so get nicked guv )
    }
    }
    else
    {
    //Start running
    }
    }

    James
    My site to register for all my other websites!
    'Clifton Bazaar'

  8. #38
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    I do it like...

    In C++ I do this

    #include <iostream.h>

    int main(int argc, char* argv[])
    {

    return 0;
    }
    +++
    ++
    + Sekti
    ++
    +++

  9. #39
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    Code:
    int main(int argc, char* argv[])
    I have rarely seen this and could anyone explain what and why there is int argc and char* argv[] ?
    My site to register for all my other websites!
    'Clifton Bazaar'

  10. #40
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,220
    argc is the number of command line arguments and *argv[] is a character array containing the programs name and command line arguments.

    argv[0] = the program's path
    argv[1] = the first argument
    and so on

  11. #41
    Unregistered
    Guest

    Thumbs up Four most popular techniques

    Well, nowadays, there are four most popular techniques of coding that are acceptable, encouraged and used in developing softwares:

    the first technique is the K&R that looks like this:

    if (cond) {
    stmt1;
    stmt2;
    ...
    }


    the second technique is called the Allman technique that goes like this:


    if (cond)
    {
    stmt1;
    stmt2;
    ...
    }


    the third would look like this:

    if (cond)
    {
    stmt1;
    stmt2;
    ...
    }

    and is called Whitesmith.



    Finally, the fourth most popular technique is the following and is known as Alternative:

    if (cond) {
    stmt1;
    stm2;
    ...
    }



    The kernighan and Ritchie style(#1) is the most widely used style since it uses slightly less vertical space than other methods. On the other hand many, like Brian, feel that it is more burdensome to match up braces with this technique.

    #2 and #3, the Allman and the Whitesmith styles are often preferred by programmers specially those who have done programming in pascal. The brace matchin is easy but extra vertical space is used.

    finally #4 is a very popular alternative to standard D&R formatting.



    What is important, Brian, is consistency. You pick any one of the acceptable styles and make sure you are consistent.

    Remember, a good programer is the one who "Writes programs for people first, computers second". So make sure your code is readable.

    tnx,
    ben




    p.s. if my codes dont look the way they should, then please let me know how to use the special editor. I will post the 4 techniques again in that case. thanks

  12. #42
    Unregistered
    Guest

    Thumbs down posted codes

    yes, unfortunately they didnt, so please let me know where to get the editor that you guys have been using.

    thanks again.
    ben

  13. #43
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    To have code displayed as it should be, use code/endcode markers. I suspect if I draw them, they will be interpreted so I will describe them!!! An opening code marker consists of the word code placed inside square brackets, the end code marker is /code in square brackets.

    Generally:

    A number of people have asked me to dig up the studies I referred too above. This I will try to do. I recall at least two of them were conducted at US universities. I had all this stuff in a file, which it would seem, I have "misplaced" or possibly has been "borrowed" by one of my colleagues. I would have thought a google search would find it though - that is what I'll be doing if I can't find the reports!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  14. #44
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    i code

    if(cond)
    {
    cout<<"LINE1";
    cout<<"LINE2";
    }
    else
    {
    cout<<"LINE3";
    cout<<"LINE4";
    }


    except in switch-case statements where i do

    switch(var)
    {
    case 1:
    cout<<"HIT TAB AND START SECT 2";
    break
    case 1:
    cout<<"HIT TAB AND START SECT 2";
    break
    }


    sometimes in multiple if-else i do

    if(cond1)
    {

    if(cond2)
    {

    if(cond3)
    {
    }

    }

    }

    bracket matching can give serious headaches...

  15. #45
    Unregistered
    Guest

    Lightbulb The four techniques, again

    Thanks to adrian, I am able to show you the four techniques once again, (I hope it works i mean...)


    #1) K&R
    Code:
        if (cond) {
             stmt1;
             stmt2;
             ...
        }

    #2) Allman
    Code:
     
        if (cond)
        {
            stmt1;
            stmt2;
            ...
         }

    #3) Whitesmith
    Code:
         if (cond)
            {
             stmt1;
             stmt2;
             ....
             }

    #4) Alternative
    Code:
           if (cond) {
               stmt1;
               stmt2;
               ...
               }
    I hope it works this time!
    tnx,
    ben

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

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