0

Hello,

I'm trying to make my code work with -Wall -Werror flags but I get the above error (error: array subscript has type char). Here is the code, which works if these flags are not set. The code is meant to check whether the first character from text is blank or not.

void processText(char *text, int *position) {
    if (isblank(text[0])) { // error: array subscript has type char
        *position = *position + 1;
        text = text + 1;
        processText(text, position);
    }
}

I've tried

isblank(atoi(&letter[0]))

and

isblank(text[0]- '0')

. They do allow it to compile with no errors under -Wall -Werror flags but the result is completely different which probably means the conversion isn't correct.

Any help is appreciated :icon_cheesygrin:

Thanks

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jangozo
0

I replaced it with isspace() and used isspace((int)text[0]) to fix it. It works now. :icon_mrgreen:

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.