Okay, if the text file is just a jumbled mess of digits and characters, then I suppose your approach makes more sense.
The core of your logic is your isCijfer and isGetal functions.
Your first issue is that in
isCijfer, ASCII value 48 is '0', which is a valid digit, but your code says
1 2
|
if (c > 48 && c < 58)
return true;
| |
Your second issue is that in
isGetal, you call invoer.get(); only once, but then never call it again when looping. So as far as I can tell, you have an infinite loop.
A questionable part of your code is:
1 2 3
|
for(j=1; j < getal; j++) {
getal=0;
}
| |
You're just assigning the same variable over and over again. The for loop is unnecessary.
___________________________
Suggestions:
1.
isdigit is already a standard C/C++ library function, so you could replace isCijfer with that.
Be sure to
#include <cctype>
2. Don't loop on .eof(). While it can work if you're careful or under certain conditions (like extracting one character at a time), it shouldn't be used as a looping condition in general. You should use the successful extraction of data as the looping condition.
3. Declare looping variables like i and j from within the for loops themselves. This makes it easier for a reader to easily tell what the lifetime of a variable is.