Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 7th, 2005, 6:03 AM   #11
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Thanks Ooble.
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old May 7th, 2005, 7:15 AM   #12
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Please look over that code and make sure you understand every single word of it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 8th, 2005, 11:48 PM   #13
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Ok, I dont understand this part:
ch &= 0xDF;
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old May 9th, 2005, 11:39 AM   #14
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That can be stretched out to ch = ch & 0xDF;, or ch = ch & 223;. What this does is remove the third bit (from the left), making the character uppercase if it's a letter. You need to understand bit mathematics and the ASCII table to understand this. Basically, it's doing the same thing as ch = toupper(ch);.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 9th, 2005, 10:23 PM   #15
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
This goes back to a little thing called "clever" programming. I prefer longer, cleaner code that is easier to read. The issue with that, Ooble, is that I'd have to whip out a hex to binary converter and actually think for once. Why not just use toupper? Much easier for both parties.
Dameon is offline   Reply With Quote
Old May 10th, 2005, 2:45 AM   #16
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 5 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
Ooble's code is more efficient but in this day and age efficiency is not required where as neat easy to unsderstand code it :/
Berto is offline   Reply With Quote
Old May 10th, 2005, 10:44 AM   #17
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
There's not much point in including an entire header file for one function. If you like, you can make your own toupper function:
char toupper (char ch)
{
    return ch & 0xDF;
}
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 12th, 2005, 4:32 AM   #18
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Quote:
Originally Posted by Ooble
That can be stretched out to ch = ch & 0xDF;, or ch = ch & 223;. What this does is remove the third bit (from the left), making the character uppercase if it's a letter. You need to understand bit mathematics and the ASCII table to understand this. Basically, it's doing the same thing as ch = toupper(ch);.
If I understand correctly this part is needed for the case that a user enter c instead of C, am I right?
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Old May 12th, 2005, 2:25 PM   #19
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Exactly.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 13th, 2005, 12:29 AM   #20
TecBrain
Hobbyist Programmer
 
Join Date: Sep 2004
Location: Cyprus
Posts: 147
Rep Power: 4 TecBrain is on a distinguished road
Very nice and efficient, I never though of this to be honest!!, thanks Ooble.
__________________
Personal Portfolio
TecBrain Support Forum
Linux VS Windows ... Dont Even Think of it ..
Distribution: Slackware
if (OS==Linux) return success
There are 10 kinds of people, those who can read binary numbers and those who can't.
TecBrain is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:52 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC