Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: full-stop

  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Malaysia
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    full-stop

    Dear sir,

    I am trying to create a program that accepts users enter a word and ends with a period (full-stop). How can C detect the full-stop from users and my do loop also can't function in properly as I want to have an error message if users enter non-alpha characters.

    char string[100];
    int counter = 0;
    clrscr();

    gotoxy(16,6); cprintf("Please enter a word and ends with a full-stop(.)");
    fflush(stdin);
    gotoxy(19,7); gets(string);

    do
    {
    if (isalpha(string[counter]) && string[counter] == '.')
    {
    strrev(string);
    gotoxy(16,10); cprintf("Sentence in reverse order.");
    gotoxy(16,11); cprintf("¯¯ %s", string);
    counter++;
    }

    else
    {
    gotoxy(16,10);
    cprintf("Error!");
    }
    }while (string[counter] != '\0');


    Thanks,

    Xiang

  • #2
    psp
    psp is offline
    New Coder
    Join Date
    Mar 2003
    Location
    CA
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Reply..fullstop

    Hello,

    See the following code.Hope it helps.

    #include<stdio.h>
    main() {
    char string[100];
    int c;
    printf("\n Please enter a word followed by a full stop");
    gets(string);
    c=0;
    while(string[c]!='\0')
    {
    c++;
    }
    if(string[--c]!='.')
    printf("not valid");
    }

    ~Chandana~


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •