Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 2
How do you capitalize a single letter in an Array of char in C++?
How do you capitalize a single letter inside an array of char in C++? Example: char *myArray[]={āhello worldā}; And capitalize only the randomly selected āhā or āoā etc? Basically how can C++ recognizes a character and know itās capital form? Do I save the capital letter for ever small letter ex: if char letter == āaā then cout āAā or ābā then cout āBā....? Will this work? And is there any other way?
2 Respostas
+ 5
#include <iostream>
#include <cctype>
int main()
{
char myArray[]={"hello world"};
char letter = toupper(myArray[0]);
std::cout << letter;
}
+ 8
you can check with condition:
if(c >= 'a' && c <= 'z')
// c is small letter
if(c >= 'A' && c <= 'Z')
// c is capital letter