- #1
Lord Anoobis
- 131
- 22
So I just completed a simple exercise that converts all letters of a string to upper case letters. The program works but it comes with the warning: comparison between signed and unsigned integer expressions [Wsign-compare].
What does this mean? While whatever is causing the warning does not seem to have any effect on the operation of the program, I would like to what is happening here in case it shows up at some point in the future and DOES cause problems. Here's the prog...
What does this mean? While whatever is causing the warning does not seem to have any effect on the operation of the program, I would like to what is happening here in case it shows up at some point in the future and DOES cause problems. Here's the prog...
Code:
#include <iostream>
#include <string>
using namespace std;
//Changes letters to upper case
void converter(string& sent_par);
int main ()
{
string sentence;
cout << "Enter a sentence: ";
getline (cin, sentence, '\n');
converter (sentence);
cout << endl << sentence << endl;
return 0;
}
void converter (string& sent_par)
{
for (int i = 0; i <= sent_par.size(); i++)
{
sent_par[i] = toupper(sent_par[i]);
}
}