Thread: Switch statement does not flow through cases

  1. #16
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by sjmp View Post
    need to terminate the program using CNTRL D - ASCII 4? that is what I was trying to do there. It works so long as long as I execute CNTRL D on a new line.
    Assuming you are on Linux/Unix, Ctrl-D signals the end of file/transmission thus
    Code:
    while ((c = getchar()) != EOF)
    is sufficient.

    Bye, Andreas

  2. #17
    Registered User
    Join Date
    Jul 2012
    Posts
    55
    Andreas
    I removed c !=4 and it no longer responded to CNTRLD, I am using windows...

  3. #18
    Registered User
    Join Date
    Jul 2012
    Posts
    55
    Got it working! for real this time

    set \t and '' to state OUT
    set \n to increment and state out
    default if char increment and fixed the word count as another if statement proceeding that.

    Thanks for everyone's help. In three months from now, when I am an expert programmer I will remember you all.

    SJ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about switch cases
    By cashmerelc in forum C Programming
    Replies: 5
    Last Post: 09-21-2007, 11:57 PM
  2. Replies: 6
    Last Post: 11-10-2005, 01:37 PM
  3. switch cases and timers
    By soranz in forum C++ Programming
    Replies: 5
    Last Post: 10-02-2005, 06:43 PM
  4. switch cases and do while
    By exoillusion in forum C Programming
    Replies: 7
    Last Post: 07-28-2003, 07:18 AM
  5. could someone please explain switch cases?
    By .exe in forum C++ Programming
    Replies: 7
    Last Post: 07-01-2003, 01:42 PM

Tags for this Thread