Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,049 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,202 people online right now. Registration is fast and FREE... Join Now!




How to write code to change lower case to upper case

 
Reply to this topicStart new topic

How to write code to change lower case to upper case

andy1988
post 5 Mar, 2008 - 01:22 PM
Post #1


New D.I.C Head

*
Joined: 4 Mar, 2008
Posts: 6

Hey,

Wonder if you could tell me how to write a code in C to change lower case letter 'i' to uppercase letter 'I' in a text file whenever it occurs on its own

For example:

one day i walked to the shop

change this to

one day I walked to the shop

Using an if statement if possible

Thanks =]

This post has been edited by andy1988: 5 Mar, 2008 - 01:41 PM
User is offlineProfile CardPM

Go to the top of the page

captainhampton
post 5 Mar, 2008 - 01:26 PM
Post #2


Jawsome++;

Group Icon
Joined: 17 Oct, 2007
Posts: 518



Thanked 2 times

Dream Kudos: 825
My Contributions


There is are functions called "toupper" and "tolower" that do just what you are asking. An example of such an instance is as follows:

cpp


char d='a';
d=toupper(d);
cout<<d;


Google "toupper c++" for a wealth more of information on the topic.
User is offlineProfile CardPM

Go to the top of the page

andy1988
post 5 Mar, 2008 - 01:44 PM
Post #3


New D.I.C Head

*
Joined: 4 Mar, 2008
Posts: 6

QUOTE(captainhampton @ 5 Mar, 2008 - 02:26 PM) *

There is are functions called "toupper" and "tolower" that do just what you are asking. An example of such an instance is as follows:

cpp


char d='a';
d=toupper(d);
cout<<d;


Google "toupper c++" for a wealth more of information on the topic.



I need code in C rather than C++, is there a way to use toupper in just C?

Ive searched on the net, but cant figure out how to use it

Thanks for your reply =]
User is offlineProfile CardPM

Go to the top of the page

spazzedout
post 5 Mar, 2008 - 02:23 PM
Post #4


New D.I.C Head

*
Joined: 3 Oct, 2007
Posts: 41


My Contributions


you can use

if( char > 'a' || char < 'z')
{
char = char - 32
}
if( char < 'A' || char > 'Z')
{
}

the above code is just an example. it wouldn't work just yet, but if you alter it correctly you should be able to get it working smile.gif
User is offlineProfile CardPM

Go to the top of the page

andy1988
post 5 Mar, 2008 - 02:55 PM
Post #5


New D.I.C Head

*
Joined: 4 Mar, 2008
Posts: 6

QUOTE(spazzedout @ 5 Mar, 2008 - 03:23 PM) *

you can use

if( char > 'a' || char < 'z')
{
char = char - 32
}
if( char < 'A' || char > 'Z')
{
}

the above code is just an example. it wouldn't work just yet, but if you alter it correctly you should be able to get it working smile.gif


This might sound obvious, but Im an absolute begginner, which parts do i change and also what does the 32 stand for?

Thanks =]
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 06:23AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month