Home c++ Using the Getche ()

Using the Getche ()

Author

Date

Category

Trying to get from the program so that it counts the number of letters and words. Visual Studio displays an error pointing to getche (). Although syntactically, it is used correctly. What is my mistake?

# include & lt; iostream & gt;
# INCLUDE & LT; Conio.h & gt;
Using Namespace STD;
INT MAIN ()
{
  int chcount = 0;
  INT WDCOUNT = 1;
  char ch = 'a';
  COUT & LT; & LT; "ENTER THE STRING:";
  While (CH! = '\ R')
  {
    ch = getche ();
    if (ch = '')
      WDCount ++;
    ELSE.
      CHCOUNT ++;
  }
  COUT & LT; & LT; "\ NWORDS" & lt; & lt; WDCount & lt; & lt; Endl;
  COUT & LT; & LT; "Letters:" & lt; & lt; (CHCOUNT - 1) & lt; & lt; Endl;
  Return 0;
}

Answer 1, Authority 100%

First your error 🙂 – you need not

if (ch = '')

a

if (ch == '')

Second – if there are several gaps in a row, you consider them words …

well, and getche () Neither (yes and, in general, in vain you are her, non-standard, use …)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions