A challange

This is a discussion on A challange within the C++ Programming forums, part of the General Programming Boards category; ...And why should you post a solution once the time is up? The code is bad practice too. Not to ...

  1. #16
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    ...And why should you post a solution once the time is up?
    The code is bad practice too.
    Not to mention unnecessarily complicated and hard to understand.
    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.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Code:
    const char *pDay[] = {"Sunday", "Monday",
                    "Tuesday", "Wednesday",
                    "Thursday", "Friday",
                    "Saturday"};
    ??

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Yep, that takes care of the bad practice part... But the code is still too complex to understand right away without digging into the code and I am not going to bother to.
    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.

  4. #19
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by matsp View Post
    Code:
    const char *pDay[] = {"Sunday", "Monday",
                    "Tuesday", "Wednesday",
                    "Thursday", "Friday",
                    "Saturday"};
    ??

    --
    Mats
    The MS compiler doesn't complain about. It's set to treat all warnings as errors. But anyway, I'll run the code thru lint Monday morning to determine if lint complains.

  5. #20
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Yep, that takes care of the bad practice part... But the code is still too complex to understand right away without digging into the code and I am not going to bother to.
    I dunno, seems like you need to understand two things predominantly: functions and arrays. The algorithm Bob used is pretty well known, it only requires some moderate research if you don't know.

  6. #21
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Quote Originally Posted by BobS0327 View Post
    The MS compiler doesn't complain about. It's set to treat all warnings as errors. But anyway, I'll run the code thru lint Monday morning to determine if lint complains.
    Not many compilers complain/warn about that.
    And did I mention I hate algorithms? Especially complex ones. They are never easy to understand.
    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.

  7. #22
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    You must hate programming then.

  8. #23
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Actually, I do not.
    Though technically a program is algorithms and data, I can still hide the algorithms in higher-level functions whose task is clear. Now that is what programming is about.
    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.

  9. #24
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Quote Originally Posted by Elysia View Post
    Not many compilers complain/warn about that.
    And did I mention I hate algorithms? Especially complex ones. They are never easy to understand.
    Lint isn't a compiler. It's a commercial application that checks source code for bugs, glitches, inconsistencies, non portable contructs and a lot more. If there is anything questionable about the source code lint will DEFINITELY complain.

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    I was referring to the MS compiler.
    I remember what Lint is. I sure do hope it points that out. Otherwise I think someone needs to file a suggestion...
    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.

  11. #26
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Hmm.... What is algorithm? :P
    No, English ain't my main language and you people make it sound as algorithm is an essential part of coding, so could anyone clear it up for me? 'Cause dictionaries don't really make sense, when I search 'algorithm' :P
    Currently research OpenGL

  12. #27
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    "A precise step-by-step plan for a computational procedure that begins with an input value and yields an output value in a finite number of steps. "
    Or in other words - it describes the process of taking a number from the user and calculates to 1000 from that number.
    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.

  13. #28
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Ohh... So it always calculates to a 1000? Or is that controllable?
    Currently research OpenGL

  14. #29
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    I disagree after "in other words" ... algorithms apply to any problem, even in real life. If you lost something you would probably use an algorithm to find it. Like, "well, I know I had it an hour ago, I'll retrace my steps to where I was an hour ago."

    That's probably the reason my psychology textbook and computer science textbook agree that an algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Even though, in psychology they usually focus on how this applies to the conscious mind and learning.

  15. #30
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Quote Originally Posted by Akkernight View Post
    Ohh... So it always calculates to a 1000? Or is that controllable?
    Of course not. It was an example.

    Quote Originally Posted by citizen View Post
    I disagree after "in other words" ... algorithms apply to any problem, even in real life. If you lost something you would probably use an algorithm to find it. Like, "well, I know I had it an hour ago, I'll retrace my steps to where I was an hour ago."

    That's probably the reason my psychology textbook and computer science textbook agree that an algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Even though, in psychology they usually focus on how this applies to the conscious mind and learning.
    Of course it was not meant to be taken literally. It was an example of a algorithm.
    I agree with the definition I took from wiktionary.
    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.

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Challange for Cprogramming.com
    By umar7001 in forum C++ Programming
    Replies: 28
    Last Post: 04-15-2007, 09:31 AM
  2. Digit selector... (Mathmatically complex, for some)
    By Axpen in forum C Programming
    Replies: 17
    Last Post: 08-28-2004, 03:58 PM
  3. Stuck on a friend's challange
    By wiresite in forum C++ Programming
    Replies: 32
    Last Post: 04-23-2004, 08:36 AM
  4. Timecard Challange
    By Thantos in forum Contests Board
    Replies: 2
    Last Post: 11-20-2003, 04:12 PM
  5. Chess Challange
    By kosmoludek in forum C Programming
    Replies: 4
    Last Post: 01-12-2003, 04:53 PM

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