Thread: C++ program in need of help!?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by Brian_of_Bozeat View Post
    Indentation etc. is personal choice unless you are working with a team (to an agreed format).
    Clear indentation is critical to code clarity. Since you are sharing your code and expecting others to read it, it's more than just a personal choice. There is more than one way to clearly indent code, but it needs to be clear where each scope is by the indentation.

    If for whatever reason your code has sloppy indentation, you should fix it when posting it for others to read.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Bozeat, Northants. UK
    Posts
    23
    chinesebarbie - your getinput function still has no return value as it is a void function. Please re-read the code I wrote earlier and try to understand how values are passed in it before modifying yours again.


    As for:
    Quote Originally Posted by King Mir View Post
    Clear indentation is critical to code clarity. Since you are sharing your code and expecting others to read it, it's more than just a personal choice. There is more than one way to clearly indent code, but it needs to be clear where each scope is by the indentation. If for whatever reason your code has sloppy indentation, you should fix it when posting it for others to read.
    No matter how right you are - The OP is clearly a complete novice, please give him a chance to get his code working before slapping him down over the niceties of whitespace conventions, his code isn't that hard to read! A polite suggestion at the end of the thread (after helping him) would be a better approach than diving in half way through with criticism.

  3. #3
    spaghetticode
    Guest
    Easy guys! I just wanted to make clear how hard it is for us to try and help if the code sample given is so difficult to read (which it is if all the blocks are put next to each other without any spacing). Surely I didn't want to start a fight over coding style best practices!

  4. #4
    Registered User
    Join Date
    Nov 2011
    Location
    Bozeat, Northants. UK
    Posts
    23
    Also - have a look at this tutorial and numbers 10 and 11 that follow it. They will help you to understand what I was trying to tell you. Best of luck.

    C++ - 9 - Functions

  5. #5
    Registered User
    Join Date
    Nov 2011
    Posts
    7
    Brain_of_Bozeat - Thanks, for the link. I spent the last couple hours watching videos ,and I think I have a better understanding of what you where trying to tell me.

    My new question is can you convert a double variable into a double array?

  6. #6
    Registered User
    Join Date
    Nov 2011
    Location
    Bozeat, Northants. UK
    Posts
    23
    Quote Originally Posted by chinesebarbie View Post
    Brain_of_Bozeat - Thanks, for the link. I spent the last couple hours watching videos ,and I think I have a better understanding of what you where trying to tell me.

    My new question is can you convert a double variable into a double array?
    I'm not sure that I understand what you are trying to do now. Please explain clearly what you are trying to do and why and I will try to help.
    (it may be that you need to watch more of bucky's videos).

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I've personally noticed that when code posted on here has very poor formatting that it is the direct cause of the problem about 50% of the time.

    In this instance I can yet again see that it is the direct cause of a compilation error.

    I wonder how much time an automatic first response that asked the poster to first indent their code properly would save...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by iMalc View Post
    I've personally noticed that when code posted on here has very poor formatting that it is the direct cause of the problem about 50% of the time.
    Yes..but the OP refuses to try fixing it ..
    Code:
    for(int counter = 1; counter < size ; counter++)
    {
            if( array [counter] < lowest)
                lowest = array [counter];
    return lowest;
    }

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by manasij7479 View Post
    Yes..but the OP refuses to try fixing it ..
    Code:
    for(int counter = 1; counter < size ; counter++)
    {
            if( array [counter] < lowest)
                lowest = array [counter];
    return lowest;
    }
    Then we can simply stop helping!
    Indentation is basics of basics, and also a sort of etiquette. You don't go around asking people to do certain things.
    If you ask someone to wash your clothes, you can at least make sure they don't stink!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  4. Replies: 18
    Last Post: 11-13-2006, 01:11 PM
  5. making a program leave a msg for background program when it closes
    By superflygizmo in forum Windows Programming
    Replies: 2
    Last Post: 02-06-2006, 07:44 PM