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

Recommended Answers

All 2 Replies

where are you getting the isblank() function from?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.