Mail Archives: djgpp/1998/04/17/23:01:29
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: problem with islower() in DJGPP
|
Date: | Fri, 17 Apr 1998 19:15:04 -0400
|
Organization: | Two pounds of chaos and a pinch of salt.
|
Message-ID: | <3537E278.2CB9@cs.com>
|
References: | <01bd6a4c$7ceff000$96968ccf AT ben>
|
NNTP-Posting-Host: | ppp211.cs.com
|
Mime-Version: | 1.0
|
Lines: | 40
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Atram Schultz wrote:
>
> Hi,
>
> I'm a beginner to C++ and I'm testing a very small program with the
> islower()
> function. For some reason, this function is returning zero whether I input
> a capital
> or a non-capital. Here's the program:
Why don't you use tolower() instead of islower()? The latter tests
whether the value is lowercase or not.
There are other bugs in your code; here's a fixed version:
#include <iostream.h>
#include <ctype.h>
int main( void ) // main must return int
{
char a;
int x;
cout << "Input a character: ";
cin >> a;
x = tolower(a);
cout << char(x) << endl; // cast to char for correct display
// put endl _after_ output, not before
return 0;
}
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | mailto:fighteer AT cs DOT com |
| ICQ UIN#: 7406319 | http://www.cs.com/fighteer/ |
| ObJoke: If Bill Gates were a robber, not only would he |
| shoot you, but he'd send you a bill for the bullets. |
---------------------------------------------------------------------
- Raw text -