#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
    int val1;
    int val2;
}twoValues;
int len(char *str){
    int count = 0;
    while (str[++count]);
    return count;
}
twoValues wordCount(char *str){
    int count = 0;
    int inWord = 0;
    int spaces = 0;
    while (*str){
        if (*str <= 32){
            inWord = 0;
            spaces++;
        } else if (!inWord) {
            inWord = 1;
            count++;
        }
        str++;
    }
    twoValues values;
    values.val1 = count;
    values.val2 = spaces;
    return values;
}
int main() {
    char *str = " hello my name is aissam hhh\n \t";
    char **array;
    twoValues result = wordCount(str);
    printf(">>> %d\n", result.val1);
    printf(">>> %d\n", result.val2);
    int length = len(str) - result.val2;
    array = malloc(length + 1);
    printf(">>> %s\n",  strtok(str, " "));
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: