...

empty

Xiang
03-22-2003, 04:48 PM
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

Jason
03-24-2003, 08:32 PM
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

Phantom
03-24-2003, 09:16 PM
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? :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum