QUOTE(baconbeastnz @ 31 May, 2008 - 03:41 PM)

awesome!! yes you were right! By running
inputLength = strlen(enterred)-1; before fgets, the length was 100? or more than the actual input.
fgets ( enterred, 100, stdin ); ::: So fgets actually changes the length of the char[] !
Worked like a charm!
No.... the strlen function does not return the length of the array. It returns the length of the string inside the array. In C/C++, any variables that you declare must be initialized, and if you don't, they will contain garbage that appears to be random.
To answer your question... the length of inputLength would be unknown, as enterred is not initialized. It could be 20, 53, or even over 100 in some cases. It's all about whereever the first null character is in the array, if any. strlen is clueless as to how you declared enterred as there is no bounds checking in C.
So let's say that enterred contains a string "A string".
enterred[0] == 'A';
....
enterred[7] == 'g';
enterred[8] == 0;
(values at indicies 9..99 are irrelevant.. as long as [8] == 0).
That zero is important... that is what strlen looks for. So, strlen(enterred) in this case is 8. For an uninitialized array filled with garbage, the result is dependent on the garbage on the stack.
Try a printf on the inputLength in the program as it is now and you'll see what I mean.
The actual issue with isdigit is that you can't give it negative numbers... which if a signed char (same as a char on your compiler) is a number from -128 to 127 (which could be with random junk), then you'll get the assertion.
If you did a memset(enterred, 0, 100) before the strlen(...), then the strlen would return a zero for the string length.
This post has been edited by perfectly.insane: 31 May, 2008 - 03:46 PM