文字处理。删除不以元音开头的单词 [英] Text processing. Deleting words not starting with vowels

查看:127
本文介绍了文字处理。删除不以元音开头的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取一个文件中的内容,以便在C中读取一个char数组。我怎样才能删除大写//或以非元音开头的单词?我真的不明白如何保存最后的c ==>如何检查元音之前是否有空格。



I am reading content from a file to be read into a char array in C. How could I delete words which are uppercase // or which start with a non-vowel? I really cant understand how to save the last c ==> how to check if you have space before vowel.

int main ()
{
    FILE* read_me = fopen("x.txt", "r");
    if (!read_me)
    printf ("NERA");
    FILE* write_me = fopen("y.txt", "w");
    char c;
    while ((c=fgetc(read_me)) != EOF && c != EOF)
    if(trink(c) == 0)
    {
        fputc(c, write_me);
    }
    {
        XXX
    }
    fclose (read_me);
    fclose (write_me);
}

int trink (char w)
{
    switch(w) {
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'I':
    case 'o':
    case 'O':
    case 'u':
    case 'U':
      return 1;
    default:
      return 0;
}
}





我的尝试:



XXX部分未知。你能不能帮助我解决这个问题。



What I have tried:

XXX part is unknown. Could you help me to sove this problem.

推荐答案

是的,在我看来我应该找到一个元音,如果我们之前有空间它是真的,当我们跳过一切都到了其他空间。这个过程是连续的
Yes indeed, in my opinion I should find a vowel and if we have space before it its TRUE, when we skip everything till other space. And this process continuous


一个简单的解决方案是使用包含当前状态的变量作为

A simple solution would be using a variable containing current state as either
  1. 处理一个有效的单词。
  2. 处理空白。
  3. 处理要跳过的单词。



然后,基于当前状态和下一个字符,您的程序可以正确地建立起来。


Then, based on current state and next char, your program could establish correctly what to do.


这篇关于文字处理。删除不以元音开头的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆