More elegant would be to introduce a test-variable. Just like this:
Code:
typedef enum {FALSE, TRUE} boolean;
char val_str (char text [])
{
char status = 'Y';
int x = 0;
boolean invalid_char = FALSE;
while (text[x] != '' && invalid_char == FALSE)
{
if (toupper (isalpha (text [x++]) == 0)) {
status = 'N';
invalid_char = TRUE;
}
}
return status;
}
Or just check status.
Code:
typedef enum {FALSE, TRUE} boolean;
char val_str (char text [])
{
char status = 'Y';
int x = 0;
boolean invalid_char = FALSE;
while (text[x] != '' && status == 'Y')
{
if (toupper (isalpha (text [x++]) == 0))
status = 'N';
}
return status;
}