How to check for dot in a string

Mar 22, 2020 at 12:08am
So , i need to check if a string has a dot, if not, the user needs to input until a string with a dot is provided.
something like this, the user needs to provide something like exmaple.txt, or .dat

Enter Input File Name: example
Error, invalid file name.

Enter Input File Name:

Mar 22, 2020 at 12:19am
If you can find "." from the string ...
http://www.cplusplus.com/reference/string/string/find_first_of/
Mar 22, 2020 at 1:04am
FYI the major operating systems all allow files without a dot. Most of the text files I use even on windows are extensionless.

if you are going to do a large # of checks, like every file on your disk, find may be slightly slower than a dumb loop as it does more work than is needed. You won't notice this until the number of names you test becomes extremely large.
Last edited on Mar 22, 2020 at 1:05am
Topic archived. No new replies allowed.