I think this is the point tmouse is trying to make.
Code:#include <stdio.h>
#include <ctype.h>
int myisprint(int value)
{
if ( value < 0 )
{
puts("Bzzzt!"); /* potentially undefined behavior */
return 0;
}
return isprint(value);
}
void foo(const char *text)
{
puts("foo");
for ( ; *text; ++text )
{
myisprint(*text);
}
}
void bar(const char *text)
{
puts("bar");
for ( ; *text; ++text )
{
myisprint((unsigned char)*text);
}
}
int main(void)
{
static const char text[] = "Ich möchte"; /* some text I googled */
foo(text);
bar(text);
return 0;
}
/* my output
foo
Bzzzt!
bar
*/