Thread: Forced writing

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    1

    Forced writing

    Greetings fellow travelers,

    Is it possible in C/C++ to make console app in which no matter what you will write it will still write only one sentence? For example, this app will write the sentence "Go left" no matter what I type. I can type another sentence or I can just keep pushing one key, it will keep writing "Go left". Thanks for suggestions

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Does the input even matter at that point?

    Maybe just:
    Code:
    for ( ; ; ) {
       int ch;
       while ((ch = getchar()) != '\n' && ch != EOF) ;
       if (ch == EOF) break;
       printf("%s\n", "Go left");
    }

  3. #3
    Banned
    Join Date
    Aug 2017
    Posts
    861
    I think it would fall into the piratical joke section.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vista design being forced on XP?
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 128
    Last Post: 03-04-2008, 12:56 PM
  2. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06:57 PM
  3. Forced to use constants
    By Night_Blade in forum C++ Programming
    Replies: 6
    Last Post: 08-08-2005, 04:30 PM
  4. Forced Breaks
    By yodoblec in forum C++ Programming
    Replies: 2
    Last Post: 06-04-2003, 07:16 PM

Tags for this Thread