I have 2 questions:
Question 1= i search in the internet and i found that everyone told don't use getch()
or getche()
in c++. so how can i get a character from user ?? for example i wrote this code so how can i replace getch with another statement ?
Question 2= i wrote this code in visual studio 2013 and it works fine but when i wrote in code block and compile whit GNU GCC compiler getchar() statement doesn't work . why ??
#include <iostream>
#include "conio.h"
using namespace std;
int main()
{
int word_counter=0,char_counter=0;
char ch;
cout<<"Enter your paragraph and press ENTER for end :\n";
cin>>ch;
while((ch=getchar())!=13)
char_counter++;
cout<<"Number of characters ="<<char_counter<<endl;
return 0;
}