I need to write a program that will tell me if all the characters in a string are alphabetic or not with a return bool giving me "true" if they are alphabetic and "false" if they are not.
I have a prototype code, but I have a strong feeling this isn't going to work. Could anyone help me with this?
1. Your code is syntactically incorrect. It won't compile because strings aren't comparable against characters. Use double quotes to enclose a string.
2. Where is the string to be checked? If I don't misunderstand your intention, then the string letter should contain only one letter.
You should better loop over the string containing the word to be checked, testing it letter by letter. A for-loop isn't a bad choice.(See References of this web page)
This is a very simple code to do this, there are countless other ways. This method won't read in any spaces. Only checks for both capital & lowercase letters.
Add flag -std=c++11 for g++. If your version of g++ does not accept it, then check from man gcc what values the -std option can have.
The thing is that the GCC's default is to support rather old version of C++ standard but with some non-standard GNU extensions. It should be better for learning to stick to latest standard, if at all possible.