Linux下用c语言:实现查询单词

c代码
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
{ 
    FILE *fp = NULL;
    char str[256] = {0};
    char dst[256] = {0};
    char *p = NULL;
    char *b = NULL;

    while(1)
    {
        printf("Please enter the query word : ");      //输入单词
        fgets(str,sizeof(str),stdin);
        str[strlen(str) - 1] = '\0';

        if (!(strcmp(str,"EXIT")))                      //EXIT退出
        {
            break;
        }
        fp = fopen("dict.txt","r");                     //打开词典
        if (fp == NULL)
        {
            perror("fail to fopen\n");
            return -1;
        }
//查询单词   有输入的单词打印单词内容
//          无或输入错误则重新输入                       
     while(1)
        { 
            b = fgets(dst,sizeof(dst),fp);               
            if (b == NULL)
            {
                printf("Input error!!\nPlease try again\n");
                break;
            }
            p = strtok(dst," ");
            if(!(strcmp(p,str)))
            {
                printf("The word meaning : ");
                p = strtok(NULL," ");
                printf("%s ",p);
                p = strtok(NULL,"\n");
                printf("%s\n",p);
                break;
            }
        }
      
        fclose(fp);
    }

    return 0;
}

运行结果

单词dict.txt
a                indef art one

abacus           n.frame with beads that slide along parallel rods, used for teaching numbers to children, and (in some countries) for counting

abandon          v.  go away from (a person or thing or place) not intending to return; forsake; desert

abandonment      n.  abandoning

abase            v. ~ oneself/sb lower oneself/sb in dignity; degrade oneself/sb ;

abash            to destroy the self-possession or self-confidence of:disconcert

abashed          adj. ~ embarrassed; ashamed

abate            v. make or become less

abattoir         n. = slaughterhouse (slaughter)

abbess           n. woman who is head of a convent or nunnery

abbey            n.  buildingin which monks or nuns live as a community under an abbot or abbess

abbot            n. man who is head of a monastery or abbey

abbreviate       v. ~ sth shorten (a word, phrase, etc), esp by omitting letters

abbreviation     n.  abbreviating or being abbreviated

abdicate         v.  resign from or formally renounce the throne

abdication       giving up control, authority

abdomen          n.  part of the body below the chest and diaphragm, containing the stomach, bowels and digestive organs

abdominal        adj. in, of or for the abdomen

abduct           v. take away illegally, using force or deception; kidnap ;

abduction        A carrying away of a person against his will, or illegally.

abed             In bed; on a bed.

aberrant         adj. not following the normal or correct way

aberration       n.  deviation from what is accepted as normal or right

abet             v.  ~ sb (in sth) help or encourage sb to commit an offence or do sth wrong

abeyance         n. be in abeyance; fall/go into abeyance (of a right, rule, problem, etc) be suspended temporarily; not be in force or use for a time

abhor            v. feel hatred and disgust for (sb/sth); detest

abhorrence       n. hatred and disgust

abhorrent        adj. ~ disgusting; hateful

abidance         An abiding.

abide            v.  (esp with can/could, in negative sentences or questions can/could) tolerate (sb/sth); endure; bear

abiding          adj. enduring; permanent

ability          n.  capacity or power to do sth physical or mental

abject           adj.  wretched; hopeless

abjure           v. promise or swear to give up (a claim, an opinion, a belief, etc); renounce formally

ablaze           adj.  burning; on fire

able             adj. be ~ to do sth have the power, means or opportunity to do sth

able-bodied      adj. healthy, fit and strong

ablution         n. (fml or joc ) ceremonial washing of the body, hands, sacred vessels, etc

ably             adv. in an able manner

abnegate         vt. to give up (rights or a claim, for example); renounce.

abnegation       n.  denial or renunciation (of a doctrine)

abnormal         adj. different, esp in an undesirable way, from what is normal, ordinary or expected

abnormally       adv: abnormally large feet

aboard           adv. part, prep on or into a ship, an aircraft, a train or a bus ,

abode            n.  house; home

abolish          v. end the existence of

abolition        n. abolishing or being abolished

abolitionism     principles or measures fostering abolition especially of slavery

abolitionist     n. person who favours abolition, esp of capital punishment

abominable       adj.  ~(fml ) causing disgust; detestable

abominate        v. feel hatred or disgust for (sth/sb); detest; loathe

abomination      n.  feeling of disgust and extreme hatred

aboriginal       adj. inhabiting a land from a very early period, esp before the arrival of colonists

aborigine        n. aboriginal inhabitant

abortive         adj. coming to nothing; unsuccessful

abound           v.  be very plentiful; exist in great numbers

about            adv.  a little more or less than; a little before or after; approximately .;

above            adv.  at or to a higher point; overhead

aboveboard       be in a straightforward manner

abracadabra      n, interj meaningless word said as a supposedly magic formula esp by conjurors while performing magic tricks

abrade           v. wear away by rubbing; scrape off

abraded          rubbed off/worn away by friction

abrasion         n.  scraping or wearing away; rubbing off ;

abrasive         adj.  that scrapes or rubs sth away; rough

abreast          adv.  ~ side by side (with sb/sth) and facing the same way

abridge          v. make shorter, esp by using fewer words; condense

abridgement      n.  shortening of a book, etc ,

abridgment       a shortened version of a written work

abroad           adv.  in or to a foreign country or countries; away from one's own country

abrogate         v. cancel, repeal or annul (sth)

abrupt           adj.  sudden and unexpected

abruptly         adv.

abscess          n. swollen part of the body in which a thick yellowish liquid has collected

abscission       The act of cutting off, as in a surgical operation.

abscond          v. ~go away suddenly and secretly, esp in order to avoid arrest

absence          n.  ~ being away

absent           adj.  ~ not present (at sth); at another place (than.)

absentee         n. person who is absent

absenteeism      n. frequent absence from school or work, esp without good reason ,

absinth          [ absinthe: ] a potent green alcoholic drink, technically a gin, originally having high wormwood content

absinthe         n. bitter green alcoholic drink made with wormwood and other herbs

absolute         adj.  complete; total

absolutely       adv.  completely

absolution       n. formal declaration by a priest that a person's sins have been forgiven

absolve          v. ~ sb (fml esp law , ) clear sb (of guilt); declare sb free (from blame, a promise, a duty, etc)

absorb           v.  take (sth) in; suck up

absorbed         adj. with one's attention fully held

absorbent        n, adj that is able to take in moisture, etc

absorbing        adj. holding the attention fully

absorption       n. ~ absorbing or being absorbed

abstain          v. ~  keep oneself from doing or enjoying sth, esp from taking alcoholic drinks; refrain ;

abstemious       adj. not taking much food or drink; not self-indulgent; moderate

abstention       n. ~ (from sth) abstaining, esp not using one's vote at an election

abstinence       n. ~ abstaining, esp from food or alcoholic drinks

abstinent        voluntary forbearance especially from indulgence of an appetite or craving or from eating some foods:ABSTENTION

abstract         adj.  existing in thought or as an idea but not having a physical or practical existence

abstracted       adj. thinking of other things; not paying attention ;

abstraction      n.  ~ of sth removing; taking away ;

abstruse         adj. difficult to understand

absurd           adj.  unreasonable; not sensible

absurdity        n.

abundance        n. quantity that is more than enough; plenty

abundant         adj.  more than enough; plentiful

abuse            v.  make bad or wrong use of

abusive          adj. criticizing harshly and rudely; insulting

abut             v. ~ on/against sth (of land or a building) have a common boundary or side with sth; adjoin sth

abysmal          adj.  extremely bad

abyss            n. hole so deep that it seems to have no bottom

acacia           n. any of several trees with yellow or white flowers, esp one from which gum arabic is obtained ,

academic         adj.  of schools, colleges, etc

academician      n. member of an academy

academy          n.  school for special training

accede           v. ~ (fml )  take office

accelerate       v.  make move faster or happen earlier; increase the speed of

accelerating     [ accelerate: ] to go, occur, or cause to go or occur more quickly; speed up

acceleration     n.  making or being made quicker; increase in speed

accent           n.  emphasis given to a syllable or word by means of stress or pitch

accentuate       v. make very noticeable or prominent; emphasize

accept           v.  take (sth offered) willingly

acceptable       adj. ~  worth accepting

acceptance       n.  accepting or being accepted

access           n.  ~ means of approaching or entering (a place); way in

accessible       adj. ~ that can be reached, used, etc

accession        n. ~ reaching a rank or position

accessory        n.  thing that is a useful or decorative extra but that is not essential; minor fitting or attachment

accident         n.  event that happens unexpectedly and causes damage, injury, etc

accidental       adj. happening unexpectedly or by chance

acclaim          v.  welcome (sb/sth) with shouts of approval; applaud loudly

acclaimed        welcomed with shouts and approval

acclamation      n.  loud and enthusiastic approval

acclimate        to adapt to a new temperature, altitude, climate, environment, or situation

acclivity        n. upward slope

accolade         n.  praise; approval

accommodate      v.  provide lodging or room for

accommodating    adj. easy to deal with; willing to help; obliging

accommodation    n.  (Brit) room(s), esp for living in; lodgings

accompaniment    n.  thing that naturally or often goes with another thing

accompanist      n. person who plays a musical accompaniment

accompany        v.  walk or travel with (sb) as a companion or helper; escort

accomplice       n. person who helps another to do sth wicked or illegal

accomplish       v.  succeed in doing (sth); complete successfully; achieve

accomplished     adj.  ~ skilled

accomplishment   n.  successful completion

accord           n.  peace treaty; agreement

accordance       n. in accordance with sth in agreement or harmony with sth

accordingly      adv.  in a manner that is suggested by what is known or has been said

accordion        n. portable musical instrument with a bellows, metal reeds and a keyboard .

accost           v. approach and speak to (sb) boldly

account          n.  statement of money paid or owed for goods or services

accountability   [ accountable: ] responsible to someone or for some action; answerable

accountant       n. person whose profession is to keep or inspect financial accounts

accoutre         equip

accoutrement     equipment worn by soldiers in addition to their clothing and weapons

accoutrements    n. equipment; trappings

accredit         v.  ~ sth to sb/~ sb with sth attribute to sb; credit sb with (a saying, etc)

accrete          v. to grow together; fuse; to grow or increase gradually, as by addition.

accretion        n.  growth or increase by means of gradual additions

accrue           v. ~ (from sth) come as a natural increase or advantage, esp financial; accumulate

accumulate       v.  gradually get or gather together an increasing number or quantity of get (sth) in this way

accumulation     n.

accuracy         n. precision or exactness, esp resulting from careful effort

accurate         adj.  free from error

accurately       adv.

accursed         adj.  hateful; detestable; annoying

accusation       n.  accusing or being accused

accusatory       adj. of or indicating an accusation

accuse           v. ~ sb say that sb has done wrong, is guilty (of sth) or has broken the law

accused          (Law)  the defendant or defendants appearing on a criminal charge

accuser          n.

accusingly       adv. in an accusing manner

accustom         v. ~ oneself/sb/sth to sth make oneself, etc used to sth

accustomed       adj.  usual; habitual

acerbic          (adj.) tasting sour; harsh in language or temper

acerbity         Sourness of taste, character, or tone.

acetate          n.  compound derived from acetic acid

acetic           adj. of, containing, producing, or derived from acetic acid or vinegar

ache             n. continuous dull pain

achievable       adj. that can be achieved

achieve          v.  gain or reach (sth), usu by effort, skill, courage, etc

achievement      n.  action of achieving

achromatic       designating color perceived to have zero saturation and therefore no hue, such as neutral grays, white, or black

acid             n.  substance that contains hydrogen, which can be replaced by a metal to form a salt

acidic           adj. of or like an acid

acidify          v. (cause sth to) become acid

acidity          n. state or quality of being acid

acidulous        adj. rather sharp or bitter in taste or manner

acknowledge      v.  accept the truth of admit (sth)

acknowledgement  n.  act of acknowledging

acknowledgment   Recognition.

acme             n. highest stage of development; point of perfection

acne             n. inflammation of the oil-glands of the skin, producing red pimples on the face and neck

acolyte          n.  person who helps a priest in certain church services

acorn            n.  fruit of the oak-tree, with a cup-like base .

acoustic         adj.  of sound or the sense of hearing

acoustically     adv. The hall is excellent acoustically

acoustics        n.  qualities of a room, hall, etc that make it good or bad for carrying sound

acquaint         v. ~ sb/oneself with sth make sb/oneself familiar with or aware of sth

acquaintance     n.  ~ with sth/sb knowledge of sth/sb

acquainted       adj.  ~ with sth familiar with sth

acquiesce        v. ~ (fml ) accept sth without protest; offer no opposition (to a plan, conclusion, etc)

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值