472,331 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,331 software developers and data experts.

Convert char* to upper case

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;
}

Feb 16 '07 #1
13 23583
RishiD <ri****@gmail.comwrote:
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.
Feb 16 '07 #2
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.
Feb 16 '07 #3
Christopher Benson-Manica wrote:
>RishiD <ri****@gmail.comwrote:
>>... 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 ]
Feb 16 '07 #4
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.
Feb 16 '07 #5
Roberto Waltman wrote:
[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^

???
Feb 16 '07 #6
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.

--
Er*********@sun.com
Feb 16 '07 #7
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<charTFacet
....
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 ]
Feb 16 '07 #8
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.

Feb 16 '07 #9
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.

Feb 16 '07 #10
Roberto Waltman wrote:
Christopher Layne wrote:
Roberto Waltman wrote:
[OT] That would be, surprisingly, the toupper(c) or toupper(begin,end)
^^^^^^^^^^^^^^^^^^
[un-snip]
services provided in <ctype>

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<charTFacet
...
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()
Oh, provided by a ctype class, not provided by any <ctypeheader...?

Feb 16 '07 #11
Eric Sosman wrote:
Go back and read Roberto's message again, this time
paying attention to the text he quoted and responded to.
You are correct. I thought he was responding in general, not specifically to
the C++ part. Part of that may be due to the fact that I don't generally
think in any C++ mode while i'm in this NG.
Feb 16 '07 #12
"Harald van D?k" wrote:
>Roberto Waltman wrote:
>... C++ stuff ...
ct.toupper(beg,end) Converts each letter in the range between beg and
end by replacing the letter with the result of toupper()

Oh, provided by a ctype class, not provided by any <ctypeheader...?
[Still-off-topic] Beginning to get beyond my depth, (no books at hand
now.) I believe it is provided by the standard headers, but somehow
linked to (buried under?) the locale selection mechanisms.

There is also a toupper(c, loc) that will convert c to upper case IFF
it is a lower case character in locale loc.

Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Feb 16 '07 #13

"Christopher Layne" <cl****@com.anodizedwrote in message
news:11************@news-west.n...
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.
Especially since this can cause bad things to happen using the above code:
char *ptr = "test";
up(ptr);
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project
Feb 16 '07 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: programmerforhire | last post by:
Hello all, Is there a way to setup an ms-access table so that when I enter text in the 'datasheet' mode, it will automatically be converted tp...
3
by: Addio | last post by:
Hello, MSA Group, Does anyone know how to convert all UPPER CASE text to Initial Caps? I'm familiar with ucase and lcase, but don't know of any...
17
by: Janice | last post by:
char* line = "abcd"; How to convert the line to upper case and print? Any option for printf to do this? Thanx
6
by: Manish | last post by:
In my application there is need for only upper case chars.. Currently I am making entry to upper case when user leaves focus of the text control....
5
by: Mariame | last post by:
Hi Everyone, Is There a way to eliminate upper case, so the user could only write Lower Case or to transfer the Upper Case String to lower case in...
19
by: Eric Lindsay | last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case? I understand that HTML allows either upper or lower case. I also notice...
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8...
5
by: conan9 | last post by:
Hi folks,, I'm new here and having trouble to compile uppercase .... and here is my code: #include <iostream> #include <string> #include...
6
by: lenniekuah | last post by:
Hullo Awesome Helpers, Thank you for helping me earlier. I am back with new problem. I am trying to covert a TEXT String into either Lower and...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.