I'm working on a lab for school. The goal of the last exercise is to make a program that can scan a string input by the user for any words that suffer from "capslock syndrome" (i.e. words that begin with a lowercase letter and have all uppercase letters, lIKE tHIS). This is what I've got so far:
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s("");
int len;
do
{
cout<<"Enter a string. I will check it for \"caps-lock syndrome\"\n";
getline(cin, s);
cout<<endl;
cout<<s<<"\n\n";
len = s.length();
for(int i=0; i<len; i++){
if(islower(s[i])){
for(int j=i+1; j<len; j++){
if(isupper(s[j])){
cout<<s[j];
}
}
}
}
} while(!s.empty());
return 0;
}
What should happen is when the user enters a string like "cAPS lOCK is on" the resulting output should be: cAPS lOCK
And then loop back to the start of the program. The problem I'm getting now is that I can't get the full word to print (just the uppercase characters) and I can't get each word to print to its own line like I want to.