Click to See Complete Forum and Search --> : char problems
Moretic
April 15th, 2002, 09:43 AM
before anything else, I'm sitting on this kind
system: SunOS magna 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-5_10
people seem to wanna know that.
problem-> warning: subscript has type `char'
function declaration looks like this..
void do_password( CHAR_DATA *ch, char *argument )
the lines wich the compiler complains about looks like this.
while ( isspace(*argument) )
{
argument++;
}
I dont want to have that warning, how do I get rid of it?
MvH Mattias "Nallen" Holmström(Sweden,jmeholm@writeme.com)
Alexis Moshinsky
April 15th, 2002, 12:29 PM
Hi Mattias,
try to use this function:
template<class E>
bool isspace(E c, const locale& loc) const;
or make shure that isspace, defined in Your ctype.h (i guess) expect char, and not int.
Moretic
April 15th, 2002, 02:51 PM
ok, I dont understand any of what you have writen and dont know how
to implement it.
I have looked a little at ctype.h and I cant say that I understand any of that
either... here follows a summary of the function isspace() wich I found
in this systems help section.
Summary:
isspace()
Tests for any space, tab, carriage-return, newline,
vertical-tab or form-feed (standard white-space char-
acters) or for one of the current locale-defined set
of characters for which isalnum() is false. In the C
locale, isspace() returns true only for the standard
white-space characters.
please help me make a function wich does the same thing as isspace but
is of type char instead of int. I'm a newbie programmer trying to compile a
mud(www.rom.org) and removing any warnings that come my way. please...
MvH Mattias "Nallen" Holmström(Sweden,jmeholm@writeme.com)
Paul McKenzie
April 15th, 2002, 03:23 PM
What is the prototype of isspace?
The usual argument type to isspace is int. All you need to do is promote the value to an integer.
isspace((int)*argument);
Regards,
Paul McKenzie
Alexis Moshinsky
April 15th, 2002, 04:52 PM
Ok,
if You need to define what should be a white space character:
The myIsspace(char) could look like:
#define GET_MAP(map) \
map['\t' >> 3] |= (1 << ('\t' & 7)); \
map['\n' >> 3] |= (1 << ('\n' & 7))
/* Add here entries for other white characters*/
#define MAP_SIZE 32
int myIsspace(char ch)
{
int li, loopMax = MAP_SIZE / sizeof(li);
char map[MAP_SIZE];
for(li = 0; li < loopMax; li++)
map[li] = 0;
GET_MAP(map);
return map[ch >> 3] & (1 << (ch & 7));
}
You are wellcome to ask questions about.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.