Click here to Skip to main content
16,017,167 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to get running process list of Windows XP Pin
_AnsHUMAN_ 10-Nov-08 18:45
_AnsHUMAN_ 10-Nov-08 18:45 
GeneralRe: how to get running process list of Windows XP Pin
vijay.victory10-Nov-08 19:40
vijay.victory10-Nov-08 19:40 
GeneralRe: how to get running process list of Windows XP Pin
_AnsHUMAN_ 10-Nov-08 19:45
_AnsHUMAN_ 10-Nov-08 19:45 
GeneralRe: how to get running process list of Windows XP Pin
vijay.victory10-Nov-08 20:11
vijay.victory10-Nov-08 20:11 
GeneralRe: how to get running process list of Windows XP Pin
SandipG 10-Nov-08 20:28
SandipG 10-Nov-08 20:28 
QuestionHelp With A Password Verifier Pin
LilKoopa10-Nov-08 17:33
LilKoopa10-Nov-08 17:33 
AnswerRe: Help With A Password Verifier Pin
_AnsHUMAN_ 10-Nov-08 18:06
_AnsHUMAN_ 10-Nov-08 18:06 
AnswerRe: Help With A Password Verifier [modified] Pin
enhzflep10-Nov-08 18:17
enhzflep10-Nov-08 18:17 
sizeof(pass) always returns 4 - it's returning the size in bytes of the pointer that points to the string, not the actual length of the string itself..

if you change
string pass;
to
char pass[100];

and all occurances of
sizeof(pass)
to
strlen(pass)

You'll get code that correctly counts the number of letters in the password. The logic in your code then gets a bit funky, and I can't quite tell what you're trying to do there. Often things become much more clear when you separate out the individual parts of a problem into their own functions.


Might I suggest a different approach to this problem?

#include <iostream>
using namespace std;


int countNumChars(char *str)
{
//
// TODO: add code for this function
//
//
}

int countLowerChars(char *str)
{
//
// TODO: add code for this function
//
//
}

int countUpperChars(char *str)
{
//
// TODO: add code for this function
//
//
}

bool isValidPassword(char *password)
{
    int len, numberChars, lowerCaseChars, upperCaseChars;
    bool result = false;
    len = strlen(password);
    numberChars = countNumChars(password);
    lowerCaseChars = countLowerChars(password);
    upperCaseChars = countUpperChars(password);
    result = ((len==10)&&(lowerCaseChars>=1)&&(upperCaseChars>=2)&&(numberChars>=1));
    return result;
}


int main()
{
    char pass[100];

    cout << "Please enter a 10 character password.\n";
    cout << "You must make sure your password has at\n";
    cout << "least two uppercase and at least one\n";
    cout << "lowercase letter and at least 1 number.\n";

    cin >> pass;

    while (!isValidPassword(pass))
    {
        cout << "Invalid Password. Please type again.\n";
        cin >> pass;
    }

    cout << "Your password: " << pass << ", is good and accepted.\n";
    system("pause");

    return 0;
}

QuestionHow to build CSP in Vista Pin
izyani10-Nov-08 15:42
izyani10-Nov-08 15:42 
QuestionConvert total seconds to date time format Pin
Arif Liminto10-Nov-08 14:32
professionalArif Liminto10-Nov-08 14:32 
AnswerRe: Convert total seconds to date time format Pin
Randor 10-Nov-08 18:35
professional Randor 10-Nov-08 18:35 
AnswerRe: Convert total seconds to date time format Pin
_AnsHUMAN_ 10-Nov-08 18:36
_AnsHUMAN_ 10-Nov-08 18:36 
GeneralRe: Convert total seconds to date time format Pin
Arif Liminto10-Nov-08 18:53
professionalArif Liminto10-Nov-08 18:53 
QuestionDrawing a windows without system frame Pin
Nacho Chip10-Nov-08 12:54
Nacho Chip10-Nov-08 12:54 
AnswerRe: Drawing a windows without system frame Pin
enhzflep10-Nov-08 14:28
enhzflep10-Nov-08 14:28 
Questionneed help Pin
faradgi10-Nov-08 9:56
faradgi10-Nov-08 9:56 
AnswerRe: need help Pin
Perspx10-Nov-08 10:27
Perspx10-Nov-08 10:27 
AnswerSTOP SPAMMING ALL THE FORUMS Pin
leckey10-Nov-08 11:07
leckey10-Nov-08 11:07 
GeneralRe: STOP SPAMMING ALL THE FORUMS Pin
Paul Conrad10-Nov-08 14:57
professionalPaul Conrad10-Nov-08 14:57 
GeneralRe: STOP SPAMMING ALL THE FORUMS Pin
leckey10-Nov-08 15:02
leckey10-Nov-08 15:02 
QuestionHow to show a value in an Edit Textbox Pin
J_E_D_I10-Nov-08 8:37
J_E_D_I10-Nov-08 8:37 
AnswerRe: How to show a value in an Edit Textbox Pin
David Crow10-Nov-08 9:16
David Crow10-Nov-08 9:16 
GeneralRe: How to show a value in an Edit Textbox Pin
J_E_D_I10-Nov-08 9:51
J_E_D_I10-Nov-08 9:51 
AnswerRe: How to show a value in an Edit Textbox Pin
CPallini10-Nov-08 9:27
mveCPallini10-Nov-08 9:27 
Questionpragma comment for resource files Pin
Jim Crafton10-Nov-08 5:44
Jim Crafton10-Nov-08 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.