Hello, it's easy to find a solution online for each function case so here's a example
I'm not very good in C++ so it can still be better
// Example program
using namespace std;//mostly good c++ programmers don't like declaring this
//but i prefer because i don't like to use std:: (ex : std::string s = "example")
#include <iostream>
#include <string>
//Will upcase every character in difference between the first string and the second
void upCaseNonDifference(string& str, string str2){
for(int i=0;(unsigned)i<str.length();i++){
if (str[i] != str2[i]){
str[i] = toupper(str[i]);
}
}
}
//reverse the string given in parameter
void reverseStr(string& str)
{
int n = str.length();
// Swap character starting from two
// corners
for (int i = 0; i < n / 2; i++)
swap(str[i], str[n - i - 1]);
}
//upcase the difference between the given string and his reverse
void reverseAndUpCaseNonDifference(string& str){
string str2 = str;
reverseStr(str);
upCaseNonDifference(str,str2);
}
int main()
{
string s = "this , good , test";
cout << "Originally :" << s << endl;
reverseAndUpCaseNonDifference(s);
cout << "After .... :" << s;
}
I Edited my code after I noticed that i misunderstood your message.
- Edité par coukil 8 novembre 2019 à 23:26:32
uper to lower letters in c ++?.
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.