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
2010-08-12 12:07:43
+1, Yes.. That's the way...
liaK
2010-08-12 12:13:44
+1, another C++ coding standard
Stephane Rolland
2010-08-12 12:24:25
hey, i never said you should _always_ do it. it just solves the OP's problem.
Matt Joiner
2010-08-12 12:25:33
Just make sure the value you initialize it with isn't... oh no!
Beta
2010-08-12 12:30:26
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
2010-08-15 02:11:12
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
2010-08-12 12:08:23