Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Convert char* to upper case

Reply
Thread Tools

Convert char* to upper case

 
 
RishiD
Guest
Posts: n/a
 
      02-16-2007
Hi,

For some reason I am blanking this Friday morning. I have a class
constructor call Point as shown below. Trying to figure out how I can
make the arguments passed in all upper case before I set the member
variables.

Thanks for the insight.

RishiD

Point(const char* name,
const char* description,
const char* iomid,
const char* address,
const char* type,
Event* event)
{
m_strName = name;
m_strDesc = description;
m_strAddress = address;
m_strType = type;
m_strParentName = iomid;
m_Event = event;
}

 
Reply With Quote
 
 
 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      02-16-2007
RishiD <(E-Mail Removed)> wrote:

> For some reason I am blanking this Friday morning.


Starting with posting code that seems a little like C++ to
comp.lang.c? (It has indeed been a lengthy week.)

> I have a class
> constructor call Point as shown below. Trying to figure out how I can
> make the arguments passed in all upper case before I set the member
> variables.


There's no builtin C function to do this, but you could write one
using the builtin toupper() for characters. Alternatively, there
might be a C++ way to do this, if you are indeed writing C++ as it
seems.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      02-16-2007
RishiD said:

> Hi,
>
> For some reason I am blanking this Friday morning. I have a class
> constructor call Point as shown below.


....which makes me think you're using C++, so I've cross-posted this
reply to comp.lang.c++, and set followups to that group.

> Trying to figure out how I can
> make the arguments passed in all upper case before I set the member
> variables.


In C, you'd probably write a function that calls toupper() in a loop -
but in C++ there may be a more C++y way to do it.

[Remainder of your article retained, for clc++'s convenience. Hi guys,
long time no see.]

>
> Thanks for the insight.
>
> RishiD
>
> Point(const char* name,
> const char* description,
> const char* iomid,
> const char* address,
> const char* type,
> Event* event)
> {
> m_strName = name;
> m_strDesc = description;
> m_strAddress = address;
> m_strType = type;
> m_strParentName = iomid;
> m_Event = event;
> }


--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Roberto Waltman
Guest
Posts: n/a
 
      02-16-2007
Christopher Benson-Manica wrote:
>RishiD <(E-Mail Removed)> wrote:
>>... Trying to figure out how I can
>> make the arguments passed in all upper case before I set the member
>> variables.

>
>There's no builtin C function to do this, but you could write one
>using the builtin toupper() for characters. Alternatively, there
>might be a C++ way to do this, if you are indeed writing C++ as it
>seems.


[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
services provided in <ctype>

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
 
Reply With Quote
 
Christopher Layne
Guest
Posts: n/a
 
      02-16-2007
RishiD wrote:

> Hi,
>
> For some reason I am blanking this Friday morning. I have a class
> constructor call Point as shown below. Trying to figure out how I can
> make the arguments passed in all upper case before I set the member
> variables.
>
> Point(const char* name,
> const char* description,
> const char* iomid,
> const char* address,
> const char* type,
> Event* event)
> {
> m_strName = name;
> m_strDesc = description;
> m_strAddress = address;
> m_strType = type;
> m_strParentName = iomid;
> m_Event = event;
> }


#include <ctype.h>

void up(char *q)
{
unsigned char c;

while (*q) { c = *q; *q = toupper(c); q++; }

return;
}

Also your function specifies "const char *". You might want to adhere to that.
 
Reply With Quote
 
Christopher Layne
Guest
Posts: n/a
 
      02-16-2007
Roberto Waltman wrote:

> [OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

^^^^^^^^^^^^^^^^^^

???
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      02-16-2007
Christopher Layne wrote On 02/16/07 11:07,:
> Roberto Waltman wrote:
>
>
>>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

>
> ^^^^^^^^^^^^^^^^^^
>
> ???


Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Roberto Waltman
Guest
Posts: n/a
 
      02-16-2007
Christopher Layne wrote:

>Roberto Waltman wrote:
>> [OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

> ^^^^^^^^^^^^^^^^^^


Off-topic, wearing a C++ hat:
From Josuttis "The C++ Standard Library", 1st ed, 10th printing, page
716.

The facet ctype is a template class parameterized with a character
type...
....
Table 14.16. Services defined by the ctype<charT> Facet
....
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
 
Reply With Quote
 
=?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Guest
Posts: n/a
 
      02-16-2007
Eric Sosman wrote:
> Christopher Layne wrote On 02/16/07 11:07,:
> > Roberto Waltman wrote:
> >
> >
> >>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

> >
> > ^^^^^^^^^^^^^^^^^^
> >
> > ???

>
> Go back and read Roberto's message again, this time
> paying attention to the text he quoted and responded to.


The C++ part? toupper(begin,end) is new to me if it's valid at all,
regardless of which language is used.

 
Reply With Quote
 
=?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Guest
Posts: n/a
 
      02-16-2007
Eric Sosman wrote:
> Christopher Layne wrote On 02/16/07 11:07,:
> > Roberto Waltman wrote:
> >
> >
> >>[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)

> >
> > ^^^^^^^^^^^^^^^^^^
> >
> > ???

>
> Go back and read Roberto's message again, this time
> paying attention to the text he quoted and responded to.


The C++ part? toupper(begin,end) is new to me if it's valid at all,
regardless of which language is used.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emacs, VHDL Mode - Upper Case Enum Values & Upper Case Constants (not working)? BlackHelicopter VHDL 0 01-31-2013 04:12 AM
Regular Expression to Replace UPPER Case Text with lower case text penny Perl Misc 28 03-10-2008 01:14 AM
how to convert characters to upper case in utf8 env. csanjith@gmail.com C Programming 3 03-17-2006 02:23 AM
how to convert characters to upper case in utf8 env. csanjith@gmail.com C Programming 0 03-16-2006 06:17 PM
lower case to upper case Janice C Programming 17 12-14-2004 02:35 PM



Advertisments