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

This is a discussion on is there a way to replace EOF in this loop.. within the C Programming forums, part of the General Programming Boards category; Is this another one of those pointless "can you tie your shoelaces with one hand" type of assignments?...

  1. #31
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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...

Page 3 of 3 FirstFirst 123
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, 03: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, 09:15 AM
  4. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 05:13 AM
  5. Replies: 1
    Last Post: 11-19-2001, 04:45 PM

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