Brain Salad

Get all capital letters from a string in C++

After I’ve searched on the internet for an efficient way without using other libraries except sdt, and some questions on IRC, I’ve gotten to this solution:

  #include <string>
  #include <cctype>
  using namespace std;
  int main()
    string bigString = "This Is A String That Contains Capital Letters";
    string capitalLetters = "";
    for (int i = 0; i &lt; bigString.length(); ++i)
        capitalLetters += bigString[i];

Also if you want to lowercase the letters just put bigString[i] in tolower() like this:

capitalLetters += tolower(bigString[i]);

I hope this will be usefull to all in need.