6 Replies - 14291 Views - Last Post: 15 August 2006 - 06:08 AM Rate Topic: -----

#1 brainy_creature  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 177
  • Joined: 07-August 06

why is ctype.h used as a header file?

Post icon  Posted 14 August 2006 - 10:59 AM

why is ctype.h used as a header file?
Is This A Good Question/Topic? 0
  • +

Replies To: why is ctype.h used as a header file?

#2 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1877
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: why is ctype.h used as a header file?

Posted 14 August 2006 - 11:03 AM

... because it's a header file...
Was This Post Helpful? 0
  • +
  • -

#3 brainy_creature  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 177
  • Joined: 07-August 06

Re: why is ctype.h used as a header file?

Posted 14 August 2006 - 11:15 AM

View Postskyhawk133, on 14 Aug, 2006 - 11:03 AM, said:

... because it's a header file...


no.... i mean to ask what is it's utility????????
what can i implement if i use that header file?
like if i use math.h i can perform mathematical operations... which is impossible otherwise..
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: why is ctype.h used as a header file?

Posted 14 August 2006 - 11:17 AM

http://www-ccs.ucsd.edu/c/ctype.html

It should also be noted that the ctype.h library has been deprecated, and #include<cctype> should be used instead in C++

http://www.cs.bsu.ed...ders/cctype.htm
Was This Post Helpful? 0
  • +
  • -

#5 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: why is ctype.h used as a header file?

Posted 14 August 2006 - 11:00 PM

ctype (or cctype now) contains functions and MACRO's relating to a character's type.

For instance, case conversion functions are present in this header file and inclusion of this header file is required when you use the toupper() and tolower() functions.

You can even open the ctype.h in your Text Editor and have a look at all the functions and MACROs available.
Was This Post Helpful? 0
  • +
  • -

#6 brainy_creature  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 177
  • Joined: 07-August 06

Re: why is ctype.h used as a header file?

Post icon  Posted 15 August 2006 - 05:33 AM

View Postborn2c0de, on 14 Aug, 2006 - 11:00 PM, said:

ctype (or cctype now) contains functions and MACRO's relating to a character's type.

For instance, case conversion functions are present in this header file and inclusion of this header file is required when you use the toupper() and tolower() functions.

You can even open the ctype.h in your Text Editor and have a look at all the functions and MACROs available.


oh ya.... i have encountered this toupper() function,
the goes like this-
 char ch,str[80];
for(;;)
{
do
{
printf("(E)nter grades \n");
printf("(R)eport grades \n");
gets(str);
ch=toupper(*str);
}
while(ch!='E'&& ch!='R' && ch!='Q');
switch(ch)
{
...



can you please explain what does toupper() and tolower() functions do... and how is toupper(*str) working here..?
Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: why is ctype.h used as a header file?

Posted 15 August 2006 - 06:08 AM

toupper changes a character from lower case to upper case (by changing the related ASCII values). The code you've posted is calling the toupper() function with a character pointer as the paramter. you can read about the toupper function here:
http://www.opengroup...ns/toupper.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1