Dear my friends...
I am a user of SuSE 9.1 since SuSE 6.0 until now.
I am trying to learn and practice GNU C++.
I start with this very simple program:
=====
#include
#include
#include
class menu {
public:
int pilihan;
void tampil();
};
int main(){
menu * m = new menu();
m->tampil();
return 0;
}
void menu::tampil(){
for (;;){
cout << "Menu : (S)amba (P)ostfix (B)ind (Q)uit\n";
cin >> pilihan;
switch ( toupper(pilihan) ){
case 'S':
cout << "You are administrating Samba Server" << endl;
break;
case 'P':
cout << "You are administrating Postfix Server" <<
endl;
break;
case 'B':
cout << "You are administrating BIND Server" << endl;
break;
cout << "You selected Quit. Good bye!" << endl;
case 'Q':
exit(0);
default:
cout << "***No such command!***" << endl;
break;
}
}
}
=====
I compiled it successfully, as below :
=====
patrixlinux@patrix:~/arsip/proyek/gcc/1> ls
liss liss.cpp liss.cpp~
patrixlinux@patrix:~/arsip/proyek/gcc/1> g++ -o liss
liss.cpp
In file included from
/usr/include/g++/backward/iostream.h:31,
from liss.cpp:1:
/usr/include/g++/backward/backward_warning.h:32:2:
warning: #warning This file includes at least one
deprecated or antiquated header. Please consider using
one of the 32 headers found in section 17.4.1.2 of the
C++ standard. Examples include substituting the <X>
header for the header for C++ includes, or
<sstream> instead of the deprecated header
. To disable this warning use
-Wno-deprecated.
patrixlinux@patrix:~/arsip/proyek/gcc/1> ./liss
Menu : (S)amba (P)ostfix (B)ind (Q)uit
s
====
But the problem is my program does not run as
expected. It does like this below without ending:
====
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
Menu : (S)amba (P)ostfix (B)ind (Q)uit
***No such command!***
====
I aborted with <control>-<C>.
what's wrong with my code? Lookslike my code does not
receive the pressed key properly.
Please help.
Thank you very much in advance.
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com