can u please tell me how to check whether an integer variable has a number stored in it or not?
can u please tell me how to check whether an integer variable has a number stored in it or not?
Usually, when not assigned a number, it will contain whatever junk the memory has from the running of other programs. For example, if you declare somewhere in main:
just like so, and then you write:Code:int x;
you might expect a very strange and arbitrary number, such as -83239 or something like it. Therefore, an integer number is always likely to have something in it. Well, at least in C++. I do not know places where this does not happen, as EVOex says. But anyway, whatever you are placing in the memory has to contain something. Having nothing in it is not likely possible at all.Code:cout << x;
He probably means input validation:
Code:int x; if (std::cin >> x) { //x has a number } else { //input failed }
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
ya i meant input validation...... i thank u all for your help......