2020-09-23, 11:50 AM
Search works fine, but you don't want search. `s` can contain `@`, so if you type `[email protected]` sscanf will do the following:
`s[32]` - Gathers everything until the first separator (whitespace by default), so `[email protected]`.
`'@'` - Looks for another `@`, but there isn't one, so the check fails.
You are missing up searches and delimiters. sscanf doesn't have look-ahead/look-behind, so while it is reading a string it doesn't know that the NEXT instruction is to look for an `@`. You've not told sscanf to stop reading strings at `@`, so it doesn't. You want:
"p<@>s[32]s[32] "
(you also don't want to check for a `.`, as valid e-mail addresses don't have to have one. Really all you want is `strfind(input, "@") != -1` - that's the simplest way to look for a valid e-mail address. Of course the only truly correct way is to send an e-mail it it.
`s[32]` - Gathers everything until the first separator (whitespace by default), so `[email protected]`.
`'@'` - Looks for another `@`, but there isn't one, so the check fails.
You are missing up searches and delimiters. sscanf doesn't have look-ahead/look-behind, so while it is reading a string it doesn't know that the NEXT instruction is to look for an `@`. You've not told sscanf to stop reading strings at `@`, so it doesn't. You want:
"p<@>s[32]s[32] "
(you also don't want to check for a `.`, as valid e-mail addresses don't have to have one. Really all you want is `strfind(input, "@") != -1` - that's the simplest way to look for a valid e-mail address. Of course the only truly correct way is to send an e-mail it it.