title: Check if the input is a number or string in C++
body: <p>I wrote the following code to check whether the input(answer3) is a number or string, if it is not a number it should return "Enter Numbers Only" but it returns the same even for numbers. Please suggest me a solution.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;typeinfo&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  
  using namespace std; 
  int main ()
  {
  
  string ques1= "Client's Name :";
  string ques2 = "Client's Address :";
  string ques3 = "Mobile Number :";
  
  char answer1 [80];
  string answer2;
  int answer3;
  
       cout&lt;&lt;ques1&lt;&lt;endl;    
       cin&gt;&gt;answer1;      
  
       cout&lt;&lt;ques2&lt;&lt;endl;    
       cin&gt;&gt;answer2; 
  
       cout&lt;&lt;ques3&lt;&lt;endl;
       cin&gt;&gt;answer3;
  
         if (isdigit(answer3))
         {
                cout&lt;&lt;"Correct"&lt;&lt;endl;     
  
                }
  
          else
          {
            cout&lt;&lt;"Enter Numbers Only"&lt;&lt;endl;  
  
              }
  
   system("pause&gt;null");
   return 0;  
  
  }
  </code></pre>