| Sunny101 (66) | |||
|
These all fail to work. I have no idea why. Any help is appreciated. p1 is user entered char string. Another code array sets the string as 'p' if it passes the validation Thanks, nela
| |||
|
|
|||
| naraku9333 (919) | |||
Try this
Edit: Same goes for the other two tests. | |||
|
Last edited on
|
|||
| Sunny101 (66) | |
| But if i starts at 0, would it not start searching the char array from the beginning? | |
|
|
|
| Sunny101 (66) | |
| It works perfectly now! Thanks! I'm still confused on why it works when code[] is moved up. Could you elaborate? | |
|
|
|
| naraku9333 (919) | |
| Initially set it to false, then set it true ONLY if the condition is met at least once. | |
|
|
|
| MikeyBoy (175) | |
|
The problem was that code[1] was only ever storing the most recent comparison result. Imagine your string was: "aBc". The first time through the loop, it sees 'a' is not upper-case, and sets code[1] to be 'F'. The second time, it sees 'B' is upper-case, and sets code[1] to be 'T'. The third time, it sees 'c' is lower-case, and sets code[1] to be 'F'. The final value of code[1] is therefore 'F'. If you used a debugger - or even just got your code to output some debugging information to stdout, you would have been able to see the changing value of code[1] for yourself, and seen what was happening. | |
|
|
|