Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
Thank you Lloyddean, I think this is exactly what I was looking for.

That might be what you think you were looking for, but if you really want to learn programming I urge you to consider my first reply instead of being spoon-fed solutions. Since you claim it isn't homework, you really should be more interesting in coming up with the answer yourself instead of just getting some code and moving on.

To be fair, you give the impression that you don't even want to try solving the question yourself. The replies in this thread demonstrate some of the different approaches posters can have to that attitude.
 
Also, I have no idea what most of your code even means. I have no clue about half the stuff you wrote.

It's a fairly simple skeleton for a standard C89 program. If you don't know what it means, now would be a good time to learn instead of whining about having no clue about it.

It would be surprising that you're on a chapter about loops in a book on the C programming language and have not yet learned what stdio.h and stdlib.h are, there's a serious problem with that book. The first chapter should have introduced you to a Hello World type program which needs to use the printf command, which requires stdio.h and the EXIT_SUCCESS constant used in valid C89 is defined in stdlib.h.

Also, all lines in a program that start with # are pre-processor macros. This should have been covered in the chapter on compiling code, something, even before the Hello World example in a good book. These are things you need to understand before trying fancy constructs like removing bodies from loops (which is just a futile exercise in compacting code and has no actual impact on the execution of instructions).

EDIT: looking up the book you're using, Chapter 3 should have explained about stdio.h since it is the chapter on formatted input/output and it seems they post-pone pre-precessor directives (of which #include is one) to chapter 14.
 
Last edited:
It's a fairly simple skeleton for a standard C89 program. If you don't know what it means, now would be a good time to learn instead of whining about having no clue about it.

It would be surprising that you're on a chapter about loops in a book on the C programming language and have not yet learned what stdio.h and stdlib.h are, there's a serious problem with that book. The first chapter should have introduced you to a Hello World type program which needs to use the printf command, which requires stdio.h and the EXIT_SUCCESS constant used in valid C89 is defined in stdlib.h.

Also, all lines in a program that start with # are pre-processor macros. This should have been covered in the chapter on compiling code, something, even before the Hello World example in a good book. These are things you need to understand before trying fancy constructs like removing bodies from loops (which is just a futile exercise in compacting code and has no actual impact on the execution of instructions).

EDIT: looking up the book you're using, Chapter 3 should have explained about stdio.h since it is the chapter on formatted input/output and it seems they post-pone pre-precessor directives (of which #include is one) to chapter 14.

Well, since you have done the research on the book I'm using, you now know what's included in the first 6 chapters.

First of all, stdio.h was not one of the things that I specifically mentioned that I didn't know, nor was exposed to yet. The other things that I listed specifically as a reply to your post, as you can clearly see now, have not been covered yet. There was no chapter specifically dedicated to "pre processor" macros/compiling code as you suggest there should've been. I've only been introduced to stdio.h and #include so far. If you have a problem with the book, take it up with the author, not me. I'm sure he would be interested in your opinion and comparing his book with yours.;) (automatic smiley) You also mention, "and the EXIT_SUCCESS constant used in valid C89 is defined in stdlib.h." (it has not been introduced yet either)

This particular book was recommended by many different people when I Googled C Programming on the web, so I went with this one.

I wasn't whining as you now accuse me of. Your answer was verbose, and overcomplicated what was being asked. (remember I did thank you) However you want to take this all personally, then come back with accusations of whining. If I recall, I never said anything that offended you. YOU were the one that suggested you were "doing my homework again". I don't recall,(as you have since not repudiated) your ever helping me with any of my numerous previous posts. So the "again" comment must have been meant for somebody else.

You unsuccessfully attempted to figure out my life, and created a make believe world in which I was going to school, and had just started a semester, meanwhile asking you to "again" do my homework for me, only to never be heard from again after my semester ends. I've been on chapter 6 now for 3 weeks I believe, because I've been busy. But if you've been "helping" me so much, you probably know that by now. And in what school or what course could somebody still be on the same exercises from the same chapter for 3 weeks?

While I appreciate everybody's feedback and help, your attitude and the unnecessary comments in your posts are out of line and rude. You need to be a bit more mature and decide if you want to help people or not, without embedding insults within your posts. You don't need to show everybody how smart you are by making a beginner look stupid. Unless all programmers think exactly like you, I'm sure you're probably difficult to work with too. I'm quite certain there are many things that different people understand that you probably know nothing about, as it's not your area of expertise, and is theirs.

I'm going to continue with this book, chapter by chapter as the author has designed it. I'm going to continue to learn the best I can by myself and ask for help when I need it. I'm going to continue to attempt to do every exercise at the back of the chapter, as I've done since I've started. (I think most instructors would probably assign specific problems, not all, as it takes a long time to do all of them) Most importantly, I'm going to continue to ask questions so that I can get what I want from life. I'm not going to allow some presumptuous know-it-all dictate to me what I should do. You won't hold me back, you can't insult me enough, you can't beat me. I'm blessed with a wonderful life, a beautiful wife and an unwavering tenacity that ensures I succeed at everything I choose to do.
 
(which is just a futile exercise in compacting code and has no actual impact on the execution of instructions).

This book does a lot of this presenting material in strange order and focusing on the esoteric before giving you the tools to get more done.

(I think most instructors would probably assign specific problems, not all, as it takes a long time to do all of them)

I also think that most instructors would fill in the gaps, provide hints, skip over the more esoteric stuff and present some of the material in the book out of order.

B
 
Since this thread seems to have devolved into bickering, it has been closed.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.