I am new here and new to C++. I am using a book to learn C++. I had this code from the book which contains conio.h library. I know this is a window thing, I want to know how may I change this code to work on Linux. I use Linux only on my machine.
Here is the code:
// showprim.cpp
// displays prime number distribution
#include <iostream>
usingnamespace std;
#include <conio.h> //for getche()
int main()
{
constunsignedchar WHITE = 219; //solid color (primes)
constunsignedchar GRAY = 176; //gray (non primes)
unsignedchar ch;
//for each screen position
for(int count=0; count<80*25-1; count++)
{
ch = WHITE; //assume it’s prime
for(int j=2; j<count; j++) //divide by every integer from
if(count%j == 0) //2 on up; if remainder is 0,
{
ch = GRAY; //it’s not prime
break; //break out of inner loop
}
cout << ch; //display the character
}
getch(); //freeze screen until keypress
return 0;
}
I will be grateful if you can help me. It is this getche() thing which causes me a headache with some codes in this book.