提取输入英文句子里的单词

输入
英文句子(末尾跟上EOL来提示结束)
输出
句子里的所有单词


输入
C makes it easy to shoot yourself in the foot. EOL

输出
C
makes
it
easy
to
shoot
yourself
in
the
foot

参考模板
#include <stdio.h>
#include <string.h>

void remove_symbol(char word[], char new_word[])
{
    int i = 0;
    int j = 0;

    for ( ) {
        if (( ) || ( )) {
           
        }
    }

    new_word[j] = ;
}

int main(void)
{
    const int ARR_SIZE = 256;
    char word[ARR_SIZE];
    char new_word[ARR_SIZE];

    while (1) {
        scanf("%s", word);
        if (strcmp(word, "EOL") == 0) {
            break;
        }

        remove_symbol(word, new_word);
        printf("%s\n", new_word);
    }

    return 0;
}

如下:

img

#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>

void remove_symbol(char word[], char new_word[])
{
    int i = 0;
    int j = 0;

    for (; word[i] != '\0';i++) {
        if ((word[i]>='a' && word[i]<='z') || (word[i] >= 'A' && word[i] <= 'Z')) {
            new_word[j++] = word[i];
        }
    }

    new_word[j] = '\0';
}

int main(void)
{
    const int ARR_SIZE = 256;
    char word[ARR_SIZE];
    char new_word[ARR_SIZE];

    while (1) {
        scanf("%s", word);
        if (strcmp(word, "EOL") == 0) {
            break;
        }

        remove_symbol(word, new_word);
        printf("%s\n", new_word);
    }

    return 0;
}

思路:截取空格变数组,循环取出塞new_word里面。