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 3 of 3

Thread: empty

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

    empty

    Dear sir,

    I trying to create a program that request user enters a sentence. I want to have an error message if user does not enters any character. How can I create this coding???


    Beat Regards,

    Xiang

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I will do this in pseudo code since I don't know what language you need it in. basically you read in what was enterd if anything. use an if statement to find out the vlaue of the statement and echo back to the user the results...

    input_string = readln("string");
    if (input_string == ""){
    print "ERROR: you entered nothing";
    }
    else {
    print "you entered: " + input_string;
    }

    is that what you mean?


    Jason

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've seen your posts, they're normally in C.

    #include <stdio.h>

    main(void) {
    char sentence[] = '';

    printf("Please enter a sentence: ");
    getc(sentence);
    if (sentence == NULL)
    printf("\nYou didn't enter a sentence!\n");
    else {
    /* code for handling if they did enter a sentence
    }

    return 0;
    }

    Does that help? :-)


  •  

    Posting Permissions

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