question on for loop?
btrain
Posts: 4
Hello all,Newbie here, I have a little programing experience in asm & VB6, but nothing to write home about. Just got my activity bot, and seem to have hit a snag on the last part of getting text from the terminal. http://learn.parallax.com/propeller-c-start-simple/get-text-terminalget text.c works fine, password check.c works fine. But on the last part under YOUR TURN - a custom version using getChar() and manually looping through the char array - I seem to have hit a snag. The code compiles which makes it difficult to figure out what's wrong - Said my post was too long, so, attached text file explains
Comments
John Abshier
So 1st the loop for text[] needs to be limited to the length of the password (pass[7]) to check, else it's not possible to have a match - too many char, not enough char, wrong char, will always throw it to the doesn't match -
2nd forgot strcmp returns 0 by default - IF statements return 1 if true by default -
so moral is: !strcmp returns 1, if text[] is the right length and right chars, which satisfies the IF statement's true condition - almost completly crazy now - lol!