The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-28-2002
ruffenator ruffenator is offline
Registered User
  
 

Join Date: Jan 2002
Location: uk
Posts: 23
character validation

how do i validate against charcaters in c ta
  #2 (permalink)  
Old 04-29-2002
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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?
  #3 (permalink)  
Old 04-29-2002
ruffenator ruffenator is offline
Registered User
  
 

Join Date: Jan 2002
Location: uk
Posts: 23
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
  #4 (permalink)  
Old 04-29-2002
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
  #5 (permalink)  
Old 04-30-2002
ruffenator ruffenator is offline
Registered User
  
 

Join Date: Jan 2002
Location: uk
Posts: 23
not really mate, cause what i am doing is, they enter a number, which must be 1 - 3 if it is it does something, else it prints an error i can do it for outside the limits but not for charcter input.
  #6 (permalink)  
Old 04-30-2002
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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.
  #7 (permalink)  
Old 04-30-2002
ruffenator ruffenator is offline
Registered User
  
 

Join Date: Jan 2002
Location: uk
Posts: 23
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0