Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ check first character of string

#include <iostream>
#include <string>

int main() 
{
  string str{};     // creating string
  getline(cin, str);// using getline for user input
  std::cout << str; // output string namePerson
  if (str[0] >= 'a' || str[0] <= 'z')
    str[0] -= 32;
  return (0);
}
Comment

c++ first letter of string

// string::at
#include <iostream>
#include <string>

int main ()
{
  std::string str ("Test string");
  for (unsigned i=0; i<str.length(); ++i)
  {
    std::cout << str.at(i);
  }
  return 0;
}
Comment

c++ check first character of string

int main() {
    string a="HELLO";
    cout<<a[0];
}
Comment

how to know the first letter of string c++

 string car = "audi";
    char firstCharacter= car.at(0);
    cout<< firstCharacter;
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ get ascii value of char 
Cpp :: Parenthesis Checker using stack in c++ 
Cpp :: all possible permutations of characters in c++ 
Cpp :: string to char* 
Cpp :: string in cpp 
Cpp :: find max element in array c++ 
Cpp :: destructor in c++ 
Cpp :: array max and minimum element c++ 
Cpp :: divide and conquer based algorithm to find maximum and minimum of an array 
Cpp :: Quicksort taking random pivot 
Cpp :: what is c++ used for 
Cpp :: detect end of user input cpp 
Cpp :: c++ triple 
Cpp :: convert unsigned long to string c++ 
Cpp :: powershell get uptime remote computer 
Cpp :: throw exception c++ 
Cpp :: c++ initialize vector of vector with size 
Cpp :: min in c++ 
Cpp :: conditional operator in c++ 
Cpp :: detect cycle in an undirected graph 
Cpp :: vector to string cpp 
Cpp :: odd numbers 1 to 100 
Cpp :: c++ string split 
Cpp :: Reverse words in a given string solution in c++ 
Cpp :: how to delete an element in vector pair in cpp 
Cpp :: inserting element in vector in C++ 
Cpp :: size of a matrix using vector c++ 
Cpp :: how to create a file in c++ 
Cpp :: how to create a c++ templeate 
Cpp :: c++ for each loop 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =