Word converter

By A^1^T^E^A^M on Jan 29, 2009

Convert your text with small characters to CAPS characters. If you have entered numbers or CAPS words, it will show you hierogliphes

Image

#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

string conv(string text)
{
       int l,i;

       l=text.length();

       for (i=0; i<l; i++)
            text.at(i)=char(int(text.at(i))-32);
       return text;
}

int main()
{

    string text;

    cout<<"Enter text: "<<endl;

    cin>>text;

    text=conv(text);
    cout<<text<<endl;

    system("PAUSE");
    return EXIT_SUCCESS;
}

Comments

Sign in to comment.
BrAndo   -  Feb 02, 2009

you could use the function toupper() which is included with the string library instead of using those c style casts

also you could just pass the parameter in your function as a refrence like so:

void conv(string& text)
{
    for (int i = 0; i < text.length(); i++)
        text[i] = toupper(text[i]);
}

then you can call it: conv(text); instead of text=conv(text);

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.