Thread: is there a way to replace EOF in this loop..

  1. #31
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Salem View Post
    Is this another one of those pointless "can you tie your shoelaces with one hand" type of assignments?
    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.

  3. #33
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    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...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. EOF or not EOF?
    By CornedBee in forum Linux Programming
    Replies: 2
    Last Post: 09-14-2007, 02:25 PM
  2. A somewhat bizzare problem!!! - WHILE LOOP
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 03-31-2006, 07:19 AM
  3. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM
  4. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 04:13 AM
  5. Replies: 1
    Last Post: 11-19-2001, 04:45 PM