Thread: changing the values of the array elements

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    3

    changing the values of the array elements

    hey guys i'm just new here and i would like some help with my school work. what i'm trying to do is change the values inside the arrays which in this case is a country code. don't mind the country code i just made that up. i would like some help or some improvements in my code tnx. if you could reply asap it would be a great help tnx.

    * i'm using borland c++
    Attached Files Attached Files
    Last edited by yugidallin; 01-01-2013 at 04:35 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Please post you code in [code][/code] bbcode tags instead of attaching it.

    Anyway, the problems that jump out at me are:
    • You have a main function that is more than 230 lines long. Rather, functions should do one thing and do it well. Break up your main functions into smaller functions, say no more than 50 lines each.
    • Your code lacks proper indentation.
    • You use goto when it appears to be completely unnecessary. It is hard to see the structure of your code because of the lack of indentation, but my guess is that your whole goto scheme is a farce: control would have gone to the label point even without the use of goto.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    Quote Originally Posted by laserlight View Post
    Please post you code in [code][/code] bbcode tags instead of attaching it.

    Anyway, the problems that jump out at me are:
    • You have a main function that is more than 230 lines long. Rather, functions should do one thing and do it well. Break up your main functions into smaller functions, say no more than 50 lines each.
    • Your code lacks proper indentation.
    • You use goto when it appears to be completely unnecessary. It is hard to see the structure of your code because of the lack of indentation, but my guess is that your whole goto scheme is a farce: control would have gone to the label point even without the use of goto.

    thanks for the feed.
    can you show me how to do that "farce" i'm kinda newbie here , sorry for the attachment thing i'm also new to these forums

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The word "farce" refers to an action that is silly. By asking how to do that, you have committed a farce.

    Anyway, it is clear that your english expression isn't the best, so bear with us if there is misunderstanding.

    Laserlight's point is to break your code into smaller functions, post in directly with [code] tags, and it is better to avoid using "goto".
    Last edited by grumpy; 01-01-2013 at 07:27 AM.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  5. #5
    Registered User
    Join Date
    Jan 2013
    Posts
    3
    it's 2% haha

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I assign values to elements of a 2D array?
    By Karyumi in forum C Programming
    Replies: 9
    Last Post: 06-21-2012, 02:48 PM
  2. Replies: 3
    Last Post: 10-21-2010, 12:39 PM
  3. Replies: 9
    Last Post: 05-29-2010, 10:32 AM
  4. stored values in elements of array, help
    By houler in forum C Programming
    Replies: 5
    Last Post: 12-09-2004, 04:19 PM
  5. Array elements values not being assigned
    By Sardien in forum C Programming
    Replies: 4
    Last Post: 02-11-2002, 01:45 PM