Reputation:
#include <iostream>
using namespace std;
#include <curses.h> //#include <conio.h>
int main()
{
initscr();
char dir='a';
int x=10,y=10;
cout<<"Please press ENTER for EXIT...\n";
while (dir != '\r')
{
cout<<"\n Your coordinates: " << x << ", " << y;
cout<<"\n Select your destination: (N,S,E,W): ";
dir = getch();
if(dir =='n')
y--;
else if(dir=='s'))
y++;
else if(dir=='e'))
x++;
else if(dir=='w'))
x--;
}
return 0;
}
Giving error
msi@MSI-VR610:~/Desktop$ g++ adelseif.cpp -o adelseif
adelseif.cpp:5:42: fatal error: curses.h: No such file or directory
#include <curses.h> //#include <conio.h>
So i am trying to use the alternative directory curse.h and ncurse.h and other combination but it doesn t compile anyway
Upvotes: 0
Views: 1611
Reputation: 2236
You'll need to install the appropriate package; for Ubuntu, this is libncurses5-dev; for Fedora it appears to be ncurses-devel. Use your package manager (apt-get, yum, etc.) to install it.
You need to link in the library too; do this by adding "-lcurses" or "-lncurses" do your compile command (both worked on Ubuntu; I'm not sure about other distributions).
Your code has extra right parentheses in the "else if ..." lines; you'll get more detail when you compile with curses.h available.
Upvotes: 1