![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can I read a file character by character? | murtaza | Shell Programming and Scripting | 4 | 04-27-2009 05:51 AM |
| Korn: How to loop through a string character by character | shew01 | Shell Programming and Scripting | 10 | 12-02-2008 07:58 AM |
| read a variable character by character, substitute characters with something else | vipervenom25 | UNIX for Dummies Questions & Answers | 2 | 06-06-2008 03:18 PM |
| Validation of character separated lines in a file | kolesunil | UNIX for Dummies Questions & Answers | 3 | 05-27-2008 06:48 AM |
| Can i read a file character by character | karnan | Shell Programming and Scripting | 6 | 05-19-2008 02:22 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Ruffenator,
I read your other post as well but I am not sure what you're asking...it isn't hard to validate values (x >=1 && x <=3, etc) so I am not sure what you're really asking. You probably want to put up some code for us to help you or explain better? You are coding in C? Korn shell? What? |
|
||||
|
help
right guys i am coding in c yes
here is the exact problem i am asking for a number 1 - 3 to be entered, and i only want them to input 1 - 3, i have validated against input of numbers outside that range and need to know how to validate against a charcater being entered, hope this helps |
|
||||
|
So you have already checked that they've entered numbers between 1 and 3?
Then what you are saying is if (x == '1') { do something; } if (x =='2' { do s/t; etc... better yet... switch (x) { case '1': { do something: } break; case '2': { do something: } break; case '3': { do something: } break; default: printf("Please enter values between 1 and 3!"); break; } Let me know if this helps or if I understand. Gianni |
|
||||
|
I still don't understand what the issue is but you can look at:
isalpha(c) islower(c) tolower(c) isupper(c) toupper(c) isdigit(c) isalnum(c) and maybe use a combination or one or several to get what you want...(ex, if isalpha() returns TRUE(non-zero) then use tolower(c) make make all entries lowercase then do your comparison...) Good luck. |
|
||||
|
lets see
right then to make this super clear dude
if (vert >3) { prinf("too big\n"); printf("re-enter\n"); } else if (vert <1) { printf("too small\n"); printf("please re-enter\n"); } else printf("well don correct"); but if the person enters a character the program crashes , any help at all ian |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|