No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
4 Posted Topics
[url]http://www.daniweb.com/code/snippet216679.html[/url] This code is read an integer from user. is there any way, tt i can using char datatype variable to accept text only. text maximum is 30letter include string/spare. It also will do a check on the char array whether is text only. i've google around but no answer. …
int mygeti(int *result){ char *end, buff [ 13 ]; fgets(buff, sizeof buff, stdin); *result = strtol(buff, &end, 10); return !isspace(*buff) && end != buff && (*end == '\n' || *end == '\0');} < any idea that i can check the integer range too?
[Warning] It not the completed code. its just a rough idea[CODE] do{ printf("Please enter a number :") scanf("%d", &no); if (no <=0) printf("invalid"); }while(no<=0); [/CODE] Hi Guys! I've a issue with scanf. First loop the program. I entered '1', a valid input. Once i retry the program, i entered a …
[CODE]#include <stdio.h> #include <ctype.h> int mygetd(double *result){ char c, buff [ 32 ]; return fgets(buff, sizeof buff, stdin) && !isspace(*buff) && sscanf(buff, "%lf%c", result, &c) == 2 && (c == '\n' || c == '\0');} int main(void){ double value; do { fputs("Enter a floating-point number: ", stdout); fflush(stdout); } while …
The End.
anthonytan