can someone help me how to trap keywords in a simple just a simple program.. i have no idea about his.. I'm just a newbie here in C++.. i need some introduction for C++.. hope someone can help me! tnx in advance!
i mean.. if the program needs to input a number.. then how can i disable all keywords? so that there will be no bug happen.. ^_^ tnx in advance..
Do you meant input only numbers ? If that is the case use getche function to write your own scanf function where if characters entered is anything apart from number you do not take that as input.
Try this Code: #include <stdio.h> #include <conio.h> int main() { char c; while(1) { c = getch(); if(c>=48 && c<=57) printf("%c",c); } getch(); }
Its a C code but it does not differ much apart from changing printf to cout and 48 and 57 are ASCII code of numbers.
I know about conditional statements. But what i don't understand is the 48 and 57. Hope you understand my english. LoL hihihi
Ahh ok Sir. Sir can you give me some simple quiz about C++? So that i have some homework to do everynight?
Check out my other forum www.go4expert.com as it has some good interview questions on C++ for you to work on.