473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to check whether input from user minimum/maksimum example for password

4
i try to limit the user key in integer at least 1 and not more than 8. pls help me..
Oct 13 '06 #1
4 2164
Banfa
9,065 Expert Mod 8TB
Put your input statement in a loop, when they have given an input check it's value and if it is wrong print an error message and ask for another input.
Oct 13 '06 #2
i try to limit the user key in integer at least 1 and not more than 8. pls help me..

Hi Check the code below, You will get some idea

void getpass(char passwd[])
{
int ch;
while(1)
{
printf("Enter your password : ");
u_int index=0;
while((ch=getch())!=13)
{
if(index < 8)
{
passwd[index]=ch;
}
index++;
putch('*');
}
if(index <2 || index > 8)//enter key
{
printf("\nPassword should be more than 1 and less than 9 charactes");
printf("\nPress any key to enter again...");
while(!_kbhit());
system("cls");
getch();
continue;
}
else
{
passwd[index]='\0';
break;
}
}
}
int main(int argc,char* argv[])
{
char passwd[9];
getpass(passwd);
printf("\npassword : %s\n",passwd);
return 0;
}
Oct 13 '06 #3
ija
4
Hi Check the code below, You will get some idea
}
yep.. yr code looks complicated.. not really understand.. can u check this example? how the array length is not 6 as i declared?

#include <stdio.h>
#include <string.h>
main ()
{
char a[8];
int size;

clrscr();
printf("Input1 : ");
scanf("%s",&a);
length = strlen(a);
printf("\nlength this input is = %d",length);

if (length <=8)
{ ... proceed instruction here}
else
{ print error}

getch();
}
Oct 13 '06 #4
ija
4
i try the strlen just now... the program ok, no problem but new prob appear.
i have prob with this short prog (eample), output doesn't capture any Y or N char.... why ? and how to correct it?

char answer;
do
{ //some instruction goes here

printf("Are u sure to checkout ?Y/N ");
scanf("%c",&answer);
}
while((answer != 'N') || (answer != 'n');
Oct 13 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: vishal | last post by:
hi i am building aan application which will send mail to user when he registers on my site and i am checking whther the email id is working properly or not by sending his email and then cheking...
10
by: nkp | last post by:
Sorry guys, basic questions..... 1)how do you prevent negative numeric input in a text box (-2345 etc) 2)how do detect /prevent input of LESS than 8 characters in a text box( where a password must...
2
by: Nicolae Fieraru | last post by:
Hi All I have a form, with a few input boxes (number of input boxes can vary). Each input box has a name such as in1, in3, in7, etc (their names can be in any order, although increasing). I...
0
by: Joe Frank | last post by:
Howdy- I have some code that programmatically creates users in AD like so: user.Properties.Value = 512; user.CommitChanges(); // Set password user.Invoke("SetPassword", new object { password...
3
by: maxjackie | last post by:
i have code below i want use $user and $password which LoginId and password in the html code please hel me <?php session_start(); require_once('DB.php'); function validate() { $user =...
3
by: manxie | last post by:
Dear All Readers, I'm supposed to create a program with a switch and using voids to execute number of codes, that includes finding sum, average, maximum, and minimum, please read my code:...
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
82
by: happyse27 | last post by:
Hi All, I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters? Two codes below : a)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.