Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,265 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,511 people online right now. Registration is fast and FREE... Join Now!




Urgent bit about ASCII values

 
Reply to this topicStart new topic

Urgent bit about ASCII values

chadly724
12 Dec, 2006 - 04:30 AM
Post #1

New D.I.C Head
*

Joined: 26 Oct, 2006
Posts: 14


My Contributions
i'm trying to convert any lowercase letters to caps. and the code looks like this...

CODE

/*********************************************
Name:        CAPS_CONV
purpose:    convert all letters to capitals
passed:
returns:
**********************************************/
void CAPS_CONV(char sent[500])
{
    for(int k=0; k<=499; k++)
    {
        if(sent[k]>90)
            sent[k]-=32
                        cout<<sent[k];
        else
            if(sent[k]==" ")||(sent[k]<90)
                        cout<<sent[k];

         return;
         }







User is offlineProfile CardPM
+Quote Post

horace
RE: Urgent Bit About ASCII Values
12 Dec, 2006 - 04:53 AM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 4 times
Dream Kudos: 50
My Contributions
what is your problem? are you looking for the touper() function?
http://www.cprogramming.com/fod/toupper.html
User is offlineProfile CardPM
+Quote Post

chadly724
RE: Urgent Bit About ASCII Values
12 Dec, 2006 - 05:35 AM
Post #3

New D.I.C Head
*

Joined: 26 Oct, 2006
Posts: 14


My Contributions
QUOTE(horace @ 12 Dec, 2006 - 05:53 AM) *

what is your problem? are you looking for the touper() function?
http://www.cprogramming.com/fod/toupper.html



that may do the trick. will it work for an array?

thanks for the tip.
User is offlineProfile CardPM
+Quote Post

horace
RE: Urgent Bit About ASCII Values
12 Dec, 2006 - 05:46 AM
Post #4

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 4 times
Dream Kudos: 50
My Contributions
QUOTE(chadly724 @ 12 Dec, 2006 - 01:35 PM) *

QUOTE(horace @ 12 Dec, 2006 - 05:53 AM) *

what is your problem? are you looking for the touper() function?
http://www.cprogramming.com/fod/toupper.html



that may do the trick. will it work for an array?

thanks for the tip.

yes for a char[], you would need to go thru the array element by element converting each character
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Urgent Bit About ASCII Values
13 Dec, 2006 - 04:35 AM
Post #5

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Use toupper() as mentioned above.

You can even XOR a charater with 32 to change it's case.
But you gotta be sure that the character is an alphabet.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:27PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month