how to change lower case to upper case in c++ code example

Example 1: how to compare lower case character to uppercase cpp

for(int i=0;i<str.size();i++){
int c = str[i]; 
        if (islower(c))  
            str[i] = toupper(c);
}

Example 2: c++ convert lowercase to uppercase

/* toupper example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  int i=0;
  char str[]="Test String.\n";
  char c;
  while (str[i])
  {
    c=str[i];
    putchar (toupper(c));
    i++;
  }
  return 0;
}

Example 3: convert from uppercase to lowercase c++

int i = 0;
    while(str[i])
    {
        if(str[i] == std::toupper(str[i]) && std::isalpha(str[i]) == 1024)
        str[i]+= 32;
        ++i;
    }