Is this another one of those pointless "can you tie your shoelaces with one hand" type of assignments?
Is this another one of those pointless "can you tie your shoelaces with one hand" type of assignments?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yes, that's my understanding.
As I said earlier, it's fair to say "don't use functions that do the job for you, when you are learning the basics", but certainly "correct code that solves the problem in the way that the teacher expects" should not be rejected just because it uses some "we haven't got there in the book yet". Fair enough that you can't do strcpy() when learning about strings and your task is to copy a string - but to check if the result of getchar() is not EOF in a loop is valid, and not a "trick" to solve the problem easier - it's just more correct.
--
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.
I really don't think the teacher forbids the use of EOF, since it is the only way of finding the end-of-file and/or an error. There is no other way around. The "tricks" and "cheatings" use EOF, they just don't type it...