Ok I would have no problem doing this using cout <<, and cin >>, but I am having trouble doing it with ncurses.
It compiles but when I type in the name "Bob" nothing happens. I have a feeling that its not even considering the if statement because it reacts as if it wasn't even there.
Also, when I try to make name a string variable I get the errors:
Code:
#include <ncurses.h>
#include <string.h>
#include <iostream>
int row, col;
char mesg[] = "Whats your name?\n";
char name[50];
void userinput()
{
initscr();
printw("Hey! I know you.");
refresh();
getch();
endwin();
}
int main()
{
initscr();
getmaxyx(stdscr,row,col);
mvprintw(1, (col-strlen(mesg))/2, mesg);
getstr(name);
if (name == "Bob")
{
userinput();
}
refresh();
getch();
endwin();
return 0;
}
It compiles but when I type in the name "Bob" nothing happens. I have a feeling that its not even considering the if statement because it reacts as if it wasn't even there.
Also, when I try to make name a string variable I get the errors:
Code:
cpp:7: error: string does not name a type
cpp: In function int main():
cpp:23: error: name was not declared in this scope