What this code does simply is to break up a sentence into individual word, for example: you input My name is John, it returns:
- My
- name
- is
- John
I'll like to know if there's any better way to rewrite this?
int main() {
    int w_size = 0;
    bool check_bool = false;
    char l_str[81];
    char *ptr_to_word[81];
    for (char *res_p = &(l_str[0]); *res_p != '\0'; res_p++) {
        if ((*res_p != '.') && (*res_p != ',') && (*res_p != ' ') && (check_bool == false)) {
            ptr_to_word[w_size] = res_p;
            w_size++;
            check_bool = true;
        }
        if (((*res_p == '.') || (*res_p == ',') || (*res_p == ' ')) && (check_bool == true)) {
            check_bool = false;
        }
    }
    if (w_size == 0) {
        printf("no solution");
    } else {
        for (int i = 0; i < w_size; i++) {
            char *a = ptr_to_word[i];
            while ((*a != ',') && (*a != '.') && (*a != '\0') && (*a != ' ')) {
                printf("%c", *a);
                a++;
            }
            printf("\n");
        }
    }
    return 0;
}
 
     
    