728x90 AdSpace

  • Latest News

    বুধবার, ১৯ আগস্ট, ২০১৫

    Dictionary program using C language

    #include<stdio.h>
    #include<windows.h>
    void GotoXY(int x, int y)
    {
    HANDLE a;
    COORD b;
    fflush(stdout);
    b.X = x;
    b.Y = y;
    a = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(a,b);
    }
    typedef struct link
    {
    char p[50];
    char q[50];
    struct link *s;
    }node;
    node *h=NULL,*w1=NULL,*w2=NULL,*w3=NULL,*w4=NULL,*w5=0,*w6=0,*w7=0,*w8=0,*w9=0,*w10=0,*w11=0,*w12=0,*w13=0,*w14=0,*w15=0,*w16=0,*w17=0,*w18=0,*w19=0,*w20=0,*w21=0,*w22=0,*w23=0,*w24=0,*w25=0,*w26=0,*w27=0,*w28=0,*w29=0,*w30=0,*w31=0,*w32=0,*w33=0,*w34=0,*w35=0,*w36=0,*w37=0,*w38=0,*w39=0,*w40=0,*w41=0,*w42=0,*w43=0,*w44=0,*w45=0,*w46=0,*w47=0,*w48=0,*w49=0,*w50=0,*n1=NULL,*w=NULL,*src=NULL,*prev=NULL,*n=NULL,*n2=NULL;
    void create()
    {
    char word[50],mean[50];
    w1=(node*)malloc(sizeof(node));
    w2=(node*)malloc(sizeof(node));
    w3=(node*)malloc(sizeof(node));
    w4=(node*)malloc(sizeof(node));
    w5=(node*)malloc(sizeof(node));
    w6=(node*)malloc(sizeof(node));
    w7=(node*)malloc(sizeof(node));
    w8=(node*)malloc(sizeof(node));
    w9=(node*)malloc(sizeof(node));
    w10=(node*)malloc(sizeof(node));
    w11=(node*)malloc(sizeof(node));
    w12=(node*)malloc(sizeof(node));
    w13=(node*)malloc(sizeof(node));
    w14=(node*)malloc(sizeof(node));
    w15=(node*)malloc(sizeof(node));
    w16=(node*)malloc(sizeof(node));
    w17=(node*)malloc(sizeof(node));
    w18=(node*)malloc(sizeof(node));
    w19=(node*)malloc(sizeof(node));
    w20=(node*)malloc(sizeof(node));
    w21=(node*)malloc(sizeof(node));
    w22=(node*)malloc(sizeof(node));
    w23=(node*)malloc(sizeof(node));
    w24=(node*)malloc(sizeof(node));
    w25=(node*)malloc(sizeof(node));
    w26=(node*)malloc(sizeof(node));
    w27=(node*)malloc(sizeof(node));
    w28=(node*)malloc(sizeof(node));
    w29=(node*)malloc(sizeof(node));
    w30=(node*)malloc(sizeof(node));
    w31=(node*)malloc(sizeof(node));
    w32=(node*)malloc(sizeof(node));
    w33=(node*)malloc(sizeof(node));
    w34=(node*)malloc(sizeof(node));
    w35=(node*)malloc(sizeof(node));
    w36=(node*)malloc(sizeof(node));
    w37=(node*)malloc(sizeof(node));
    w38=(node*)malloc(sizeof(node));
    w39=(node*)malloc(sizeof(node));
    w40=(node*)malloc(sizeof(node));
    w41=(node*)malloc(sizeof(node));
    w42=(node*)malloc(sizeof(node));
    w43=(node*)malloc(sizeof(node));
    w45=(node*)malloc(sizeof(node));
    w46=(node*)malloc(sizeof(node));
    w47=(node*)malloc(sizeof(node));
    w48=(node*)malloc(sizeof(node));
    w49=(node*)malloc(sizeof(node));
    w50=(node*)malloc(sizeof(node));

    strcpy(w1->p,"ant");
    strcpy(w1->q,"Insects");
    strcpy(w2->p,"arm");
    strcpy(w2->q,"Shoulder");
    strcpy(w3->p,"cat");
    strcpy(w3->q,"A pet animal");
    strcpy(w4->p,"cloud");
    strcpy(w4->q,"Boulder");
    strcpy(w5->p,"beat");
    strcpy(w5->q,"Strike");
    strcpy(w6->p,"becalm");
    strcpy(w6->q,"Make Calm");
    strcpy(w7->p,"before");
    strcpy(w7->q,"Infront of");
    strcpy(w8->p,"blush");
    strcpy(w8->q,"A Rosy tint");
    strcpy(w9->p,"burst");
    strcpy(w9->q,"Break up");
    strcpy(w10->p,"cabin");
    strcpy(w10->q,"A hut");
    strcpy(w11->p,"cble");
    strcpy(w11->q,"stick of rope");
    strcpy(w12->p,"cage");
    strcpy(w12->q,"confined place");
    strcpy(w13->p,"calender");
    strcpy(w13->q,"list of days");
    strcpy(w14->p,"calf");
    strcpy(w14->q,"Young Cow");
    strcpy(w15->p,"call");
    strcpy(w15->q,"Ask to come");
    strcpy(w16->p,"carrot");
    strcpy(w16->q,"vegetable");
    strcpy(w17->p,"carton");
    strcpy(w17->q,"comic Draw");
    strcpy(w18->p,"dam");
    strcpy(w18->q,"Shut up");
    strcpy(w19->p,"damage");
    strcpy(w19->q,"Loss");
    strcpy(w20->p,"daily");
    strcpy(w20->q,"everyday");
    strcpy(w21->p,"deal");
    strcpy(w21->q,"Portion");
    strcpy(w22->p,"death");
    strcpy(w22->q,"Demise");
    strcpy(w23->p,"deed");
    strcpy(w23->q,"An act");
    strcpy(w24->p,"define");
    strcpy(w24->q,"Explain");
    strcpy(w25->p,"detest");
    strcpy(w25->q,"Strongest");
    strcpy(w26->p,"dig");
    strcpy(w26->q,"Xcabate");
    strcpy(w27->p,"dipper");
    strcpy(w27->q,"Bathes");
    strcpy(w28->p,"discord");
    strcpy(w28->q,"Dishermony");
    strcpy(w29->p,"discreete");
    strcpy(w29->q,"Separate");
    strcpy(w30->p,"dishonour");
    strcpy(w30->q,"Disgrace");
    strcpy(w31->p,"lone");
    strcpy(w31->q,"No companion");
    strcpy(w32->p,"house");
    strcpy(w32->q,"lone");
    strcpy(w33->p,"care");
    strcpy(w33->q,"Concern");
    strcpy(w34->p,"guess");
    strcpy(w34->q,"think");
    strcpy(w35->p,"late");
    strcpy(w35->q,"After a Time");
    strcpy(w36->p,"cause");
    strcpy(w36->q,"aim");
    strcpy(w37->p,"study");
    strcpy(w37->q,"Swot");
    strcpy(w38->p,"hang");
    strcpy(w38->q,"dangle");
    strcpy(w39->p,"assure");
    strcpy(w39->q,"promise");
    strcpy(w40->p,"offer");
    strcpy(w40->q,"Proposal");
    strcpy(w41->p,"love");
    strcpy(w41->q,"Intensed feeling");
    strcpy(w42->p,"hate");
    strcpy(w42->q,"Dislike");
    strcpy(w43->p,"teacher");
    strcpy(w43->q,"who teaches");


    h=w1;
    w1->s=w2;
    w2->s=w3;
    w3->s=w4;
    w4->s=w5;
    w5->s=w6;
    w6->s=w7;
    w7->s=w8;
    w8->s=w9;
    w9->s=w10;
    w10->s=w11;
    w11->s=w12;
    w12->s=w13;
    w13->s=w14;
    w14->s=w15;
    w15->s=w16;
    w16->s=w17;
    w17->s=w18;
    w18->s=w19;
    w19->s=w20;
    w20->s=w21;
    w21->s=w22;
    w22->s=w23;
    w23->s=w24;
    w24->s=w25;
    w25->s=w26;
    w26->s=w27;
    w27->s=w28;
    w28->s=w29;
    w29->s=w30;
    w30->s=w31;
    w31->s=w32;
    w32->s=w33;
    w33->s=w34;
    w34->s=w35;
    w35->s=w36;
    w36->s=w37;
    w37->s=w38;
    w38->s=w39;
    w39->s=w40;
    w40->s=w41;
    w41->s=w42;
    w42->s=w43;

    w43->s=NULL;

    }
    void group()
    {
    int x,i;
    for(i=0;i<76;i++)
    {
    GotoXY(i,30);
    printf("-");
    GotoXY(i,0);
    printf("-");
    }
    for(i=0;i<31;i++)
    {
    GotoXY(0,i);
    printf("|");
    GotoXY(76,i);
    printf("|");
    }

    GotoXY(25,1);
    printf("***DIGITAL DICTIONARY***\n");
    GotoXY(33,2);
    printf("PROJECT");
    GotoXY(28,10);
    printf("DEVELOPED BY... ");
    GotoXY(28,15);
    printf("Md. Golam Saklayen");
    GotoXY(28,16);
    printf("Department of CSE,");
    GotoXY(28,17);
    printf("Daffodil International University.");


    }
    void user()
    {
    int i=0,k,m;
    char word[10],mean[10],s1[5];
    int counter=0,j=0,a,x;
    GotoXY(50,4);
    printf("==ADD WORD==");
    GotoXY(43,10);
    printf("Word :");
    GotoXY(63,10);
    printf("Meaning :");
    for(i=40;i<55;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(40,i);
    printf("|");
    GotoXY(54,i);
    printf("|");
    }
    for(i=60;i<75;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(60,i);
    printf("|");
    GotoXY(74,i);
    printf("|");
    }
    n2=(node*)malloc(sizeof(node));
    GotoXY(42,14);
    scanf("%s", word);
    n1=h;
    while(n1!=NULL)
    {
    m=strcmp(word,n1->p);
    if(m==0)
    {
    GotoXY(45,19);
    printf("Word already exists !!!");

    break;
    }
    n1=n1->s;


    }
    if(m!=0)

    {
    GotoXY(62,14);
    scanf("%s", mean);
    strcpy(n2->p,word);
    strcpy(n2->q,mean);



    w43->s=n2;
    n2->s=NULL;

    GotoXY(45,20);
    printf("Successfully added :");
    }
    }
    void box()
    {
    int i;
    GotoXY(43,10);
    printf("Word :");
    for(i=40;i<55;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(40,i);
    printf("|");
    GotoXY(54,i);
    printf("|");
    }

    }
    int search()
    {
    GotoXY(50,4);
    printf("==SEARCHING==");
    box();
    int i=0,flag=0,k;
    char z[20];
    GotoXY(42,14);
    scanf("%s", z);
    n1=h;
    for(;;)
    {
    k=strcmp(n1->p,z);
    if(k==0)
    {
    if(i==0)
    {
    GotoXY(63,10);
    printf("Meaning :");
    for(i=60;i<75;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(60,i);
    printf("|");
    GotoXY(74,i);
    printf("|");
    }

    GotoXY(62,14);
    printf("%s",n1->q);
    src=n1;
    prev=NULL;
    flag=1;
    break;
    }
    else
    {
    GotoXY(63,10);
    printf("Meaning:");
    for(i=60;i<75;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(60,i);
    printf("|");
    GotoXY(74,i);
    printf("|");
    }
    GotoXY(62,14);;
    printf("%s",n1->q);
    src=n1;
    flag=1;
    break;
    }
    }
    if(n1->s==0)
    {
    GotoXY(52,19);
    printf("Not found !!!!");
    flag=0;
    break;
    }
    prev=n1;
    n1=n1->s;
    i++;

    }

    return flag;
    }
    int menu2()
    {
    int x,i;
    for(i=0;i<76;i++)
    {
    GotoXY(i,30);
    printf("-");
    GotoXY(i,0);
    printf("-");
    }
    for(i=0;i<31;i++)
    {
    GotoXY(0,i);
    printf("|");
    GotoXY(76,i);
    printf("|");
    }
    for(i=25;i>5;i--)
    {
    GotoXY(37,i);
    printf("|");
    }
    GotoXY(25,1);
    printf("***DIGITAL DICTIONARY***\n");
    GotoXY(3,4);
    printf("INSTRUCTIONS==>");
    GotoXY(3,7);
    printf("# Enter 1 to Insert word");
    GotoXY(3,8);
    printf("# Enter 2 to Search");
    GotoXY(3,9);
    printf("# Enter 3 to Update");
    GotoXY(3,10);
    printf("# Enter 4 to Delete");
    GotoXY(3,11);
    printf("# Enter 0 to exit");
    GotoXY(3,15);
    printf("Enter your choice :");
    GotoXY(3,16);
    scanf("%d", &x);
    //system("cls");

    return (x);


    }
    int search2()
    {
    box();
    int i=0,flag=0,k;
    char z[20];
    GotoXY(42,14);
    scanf("%s", z);
    n1=h;
    for(;;)
    {
    k=strcmp(n1->p,z);
    if(k==0)
    {
    if(i==0)
    {
    GotoXY(63,10);
    printf("Meaning :");
    for(i=60;i<75;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(60,i);
    printf("|");
    GotoXY(74,i);
    printf("|");
    }
    GotoXY(62,14);
    printf("%s",n1->q);
    src=n1;
    prev=NULL;
    flag=1;
    break;
    }
    else
    {
    GotoXY(63,10);
    printf("Meaning:");
    for(i=60;i<75;i++)
    {
    GotoXY(i,12);
    printf("-");
    GotoXY(i,17);
    printf("-");
    }
    for(i=12;i<17;i++)
    {
    GotoXY(60,i);
    printf("|");
    GotoXY(74,i);
    printf("|");
    }
    GotoXY(62,14);;
    printf("%s",n1->q);
    src=n1;
    flag=1;
    break;
    }
    }
    if(n1->s==0)
    {

    GotoXY(52,19);
    printf("Not found !!!!");
    flag=0;
    break;
    }
    prev=n1;
    n1=n1->s;
    i++;

    }

    return flag;
    }
    void update()
    {
    int k;
    char new[15];
    GotoXY(50,4);
    printf("==UPDATING==");
    k=search2();
    if(k==1)
    {

    GotoXY(45,19);
    printf("Enter Update Meaning :");
    GotoXY(43,21);
    printf("==>");
    GotoXY(47,21);
    scanf("%s", new);
    strcpy(n1->q,new);
    GotoXY(45,23);
    printf("updated smile emoticon!!");
    }

    }
    void dlt()
    {

    int flag;
    GotoXY(50,4);
    printf("==DELATING==");
    flag=search2();
    if(flag==1)
    {
    if(prev!=NULL)
    {
    prev->s=src->s;
    GotoXY(52,22);
    printf("Deletion completed");
    }
    if(prev==NULL)
    {
    h=src->s;
    GotoXY(52,22);
    printf("Deletion completed");
    }
    }
    }
    void die()
    {
    int i;
    system("cls");
    for(i=24;i<57;i++)
    {
    GotoXY(i,8);
    printf("-");
    GotoXY(i,12);
    printf("-");
    }
    for(i=8;i<13;i++)
    {
    GotoXY(24,i);
    printf("|");
    GotoXY(56,i);
    printf("|");
    }

    GotoXY(35,6);
    printf("<> EXITED <>");

    GotoXY(26,10);
    printf("*Thanks For Staying With Us*\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    }

    int main()
    {

    system("color 5b");
    int a,i;
    group();
    GotoXY(43,29);

    printf("(enter any key to continue)");
    getch();
    system("cls");
    create();
    a=menu2();
    if(a==0)
    {
    die();
    }

    while (a!=0)
    {

    switch (a)
    {

    case 1: user();break;
    case 2: search();break;
    case 3: update();break;
    case 4:dlt();break;
    }
    GotoXY(2,20);
    printf("enter any key to continue ");
    getch();
    system("cls");

    a=menu2();
    if(a==0)
    {
    die();
    }
    }

    return 0;
    }
    • Blogger Comments
    • Facebook Comments

    0 মন্তব্য(গুলি):

    একটি মন্তব্য পোস্ট করুন

    Item Reviewed: Dictionary program using C language Rating: 5 Reviewed By: Unknown
    Scroll to Top