Sylvia
8
Q:

convert to lowercase c++

    // sl is the string which is converted to lowercase 
    string sl = "Jatin Goyal"; 
  
    // using transform() function and ::tolower in STL 
    transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
3
// Include #include<bits/stdc++.h>
string s = "Jatin Goyal"; 
// using transform() function and ::tolower in STL 
transform(s.begin(), s.end(), s.begin(), ::tolower); 
3
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
    char str[] = "John is from USA.";

    cout << "The lowercase version of \"" << str << "\" is " << endl;

    for (int i=0; i<strlen(str); i++)
        putchar(tolower(str[i]));
    
    return 0;
}
2
/* 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;
}
0

New to Communities?

Join the community