-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bill Cunningham wrote:
| news:5b777$47c9ddac$cef8bf78> Are you certain that the array pass[] contains
| /exactly/ 'd', 'e', 'd', 0?
|> Is it conceivable that the array contains something else? Specifically,
|> that
|> it might contain an additional character before the terminating null
|> character? Reread the description of the fgets() function; there is a clue
|> in
|> there. Run the program again, and make note of /exactly/ what you type
|> when
|> you get the unexpected 'error' answer. Are you certain that you /only/
|> typed
|> the 'd', 'e', and 'd', keys? Or did you perhaps type something else in
|> after
|> that final 'd'? What was it? Does it fit with the description of fgets()?
|> What
|> can you do in the strcmp() call to accomodate it?
|
| I am certain that ded is all I type. Is it possible that '\0' is needed.
| I'll check fgets.
OK, I'll make it plainer: You typed
~ d
~ e
~ d
~ [Enter]
That translated to
~ 'd', 'e', 'd', '\n', 0
when you executed fgets().
So, your pass[] array contains:
~ pass[0] == 'd'
~ pass[1] == 'e'
~ pass[2] == 'd'
~ pass[3] == '\n'
~ pass[4] == 0
and when you try to compare this to "ded", you fail because
~ 'd', 'e', 'd', 0 does not match to 'd', 'e', 'd', '\n', 0
- --
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
- ---------- Slackware - Because I know what I'm doing. ------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Armoured with GnuPG
iD8DBQFHygHAagVFX4UWr64RApOxAKDOlNjPFSViKNhUtnkk46TVknr4gwCghKfk
LQi1w7gHkJhmVK1gIIDA1sw=
=+rFQ
-----END PGP SIGNATURE-----