tags:

views:

162

answers:

3

how do v find a value in an integer is garbage or not???

+8  A: 

Initialize it at point of declaration, and it can never be garbage.

Matt Joiner
+1, Yes.. That's the way...
liaK
+1, another C++ coding standard
Stephane Rolland
hey, i never said you should _always_ do it. it just solves the OP's problem.
Matt Joiner
Just make sure the value you initialize it with isn't... oh no!
Beta
This isn't entirely true... if you fail to initialize some other integer and assign that to your first integer, then it might have a garbage value. :-)
James McNellis
A: 

I guess that you mean if a string contains a valid integer. Check out scanf or the stream equivalent of c++, or Boost lexical cast

schoetbi
+1  A: 

Pass it to strfry and compare the returned value with the original.

kotlinski
Hilarious.....!
Matt Joiner