#include <iostream>
#include <string.h>
#define maxsize 100
std::string toggle(std::string str)
{
if ( str.size() > maxsize)
{
std::cout << "Size of string is too big!" << std::endl;
}
else
{
for (int i = 0 ; i < str.size() ; i++) //note here i have removed <= and instead used <
{
if (isupper(str.at(i)))
{
str.at(i) = tolower(str.at(i));
std::cout << "UPPER CASE CONVERTED TO LOWER CASE "<< str.at(i) <<" " << std::endl;
}
else
{
str.at(i) = toupper(str.at(i));
std::cout << "LOWER CASE CONVERTED TO UPPER CASE "<< str.at(i) <<" " << std::endl;
}
}
}
return str; //added this return
}
int main()
{
toggle("Hello This Is A Test");
}