![]() |
|
|
|
|
|||||||
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Negative Offset | DNAx86 | High Level Programming | 1 | 05-09-2008 05:04 PM |
| Problem with sed and negative regexpr's | ericbmn1 | Shell Programming and Scripting | 1 | 02-23-2008 02:03 AM |
| negative permissions | sickoboy | UNIX for Dummies Questions & Answers | 4 | 10-12-2006 06:49 PM |
| RegExp negative match not working | umen | Shell Programming and Scripting | 2 | 08-22-2006 01:57 PM |
| negative UID/GID?!! I can see 'em but what the hell do they mean?! | hellz | UNIX for Dummies Questions & Answers | 2 | 09-07-2001 12:18 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
C++ how to isdigit() a negative number?
hi people,
I have a function which I am passing a stream which is basically postfix notation Code:
if(isdigit(in.peek()))
{
in >> number;
nums.push(number);
}
else if (strchr("+-*/", in.peek( )) != NULL)
{
in >> symbol;
do_operation(symbol, nums, okay);
}
else
{
in.ignore();
}
Code:
2 -3 + the problem is that isdigit(in.peek()) is reading the '-' as a char and not part of the negative number..... what can I do? Cheers in advance |
| Forum Sponsor | ||
|
|
|
|||
|
isdigit() is doing what it is supposed to do. It filters out the character stream into digits and non-digits. So the minus will be discarded as not being a digit. Change the code so that it skips over the sign and after reading in the digit prepend the sign to it.
|
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|