[Courses] re: [C] lesson 7

Bidea Cristian phaser_programmer at yahoo.com
Wed Nov 6 00:14:25 EST 2002


 
I don't know if this is absolutely necessary, but I want to make some observations:


It seems that the C programming language doesn't have BOOLEAN,
in it like Pascal does. In Pascal, the Boolean data type returns
true or false. So, using the Boolean type, Pascal programmers
can create functions (procedures) like: isvowel(ch), or isdigit(ch).
--------------------------------

OK! Is true, in C there is no boolean data, but (there is but :-) you can simulate the boolean data. The boolean data is practically an integer data type that can have only two values 0 and 1. But in other languages you can say "true" instead of 1 and "false" instead of 0. You can do this this in C with the #define directive:

#define boolean int

#define false 0

#define true 0

Or in C++ with

typedef enum boolean{false, true};

OK! That's all! Bye! Peace :)

-----------------------------
The C Standard library does have the following predefined functions
in the header:

Function | Description
---------+------------------------------------
isalnum | Test for Alphanumeric
isalpha | Test for Alphabetic
iscntrl | Test for Control Character
isdigit | Test for Digit
isgraph | Test for Graphical Character
islower | Test for Lower-Case Letter
isprint | Test for Printing Character
ispunct | Test for Punctuation Character
isspace | Test for White-Space Character
isupper | Test for Upper-Case Letter
isxdigit | Test for Hex Digit
---------+-------------------------------------

Happy Programming!
--
K

On Sun, Nov 03, 2002 at 04:29:39PM -0500, Morgon Kanter wrote:
> Hello,
> 
> After doing the lesson 7 excercises, I thought it would be a good idea to 
> make a header file of some of the common stuff we'd been doing. So here is 
> one of the excercises.
> 
> char consonent_or_vowel(char letter) {
> char returnchar[10];
>
> 
> 
> returnchar = "consonent";
> break;
> default:
> returnchar = "vowel";
> break;
> }
> return returnchar;
> }
> 
> If I made an error, please let me know.
> 




---------------------------------
Do you Yahoo!?
HotJobs - Search new jobs daily now-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://linuxchix.org/pipermail/courses/attachments/20021105/c99a6eba/attachment.xhtml


More information about the Courses mailing list