string name;
getline (cin, name);
// read a whole line into the string name(works like ase gets() )
//swaping
string s1,s2;
cin>>s1>>s2;
swap(s1,s2);
//we could convert the first character of a string to upper case with the following code
string s= "hello";
s[0] = toupper(s[0]);
//we could use that method to control a loop that allows us to convert all the characters to upper case
for (string::size_type i = 0; i < str.length(); i++)
{
str[i] = toupper (str[i]);
}
// for lowercase we can use tolower() function
to find posintion of a character or substring
string s;
cin>>s;
int p= s.find('a'); ///to find first occurence of a character or substring
int q= s.rfind('a'); ///to find last occurence of a character or substring
cout<<p;
getline (cin, name);
// read a whole line into the string name(works like ase gets() )
//swaping
string s1,s2;
cin>>s1>>s2;
swap(s1,s2);
//we could convert the first character of a string to upper case with the following code
string s= "hello";
s[0] = toupper(s[0]);
//we could use that method to control a loop that allows us to convert all the characters to upper case
for (string::size_type i = 0; i < str.length(); i++)
{
str[i] = toupper (str[i]);
}
// for lowercase we can use tolower() function
to find posintion of a character or substring
string s;
cin>>s;
int p= s.find('a'); ///to find first occurence of a character or substring
int q= s.rfind('a'); ///to find last occurence of a character or substring
cout<<p;
No comments:
Post a Comment