Click here to Skip to main content
14,331,836 members

C / C++ / MFC

 
AnswerRe: Re initializing an array in C++ ? Pin
Richard MacCutchan26-Dec-18 22:29
protectorRichard MacCutchan26-Dec-18 22:29 
AnswerRe: Re initializing an array in C++ ? Pin
Vaclav_27-Dec-18 6:02
memberVaclav_27-Dec-18 6:02 
GeneralRe: Re initializing an array in C++ ? Pin
Richard MacCutchan27-Dec-18 6:54
protectorRichard MacCutchan27-Dec-18 6:54 
GeneralRe: Re initializing an array in C++ ? Pin
Victor Nijegorodov27-Dec-18 7:16
memberVictor Nijegorodov27-Dec-18 7:16 
AnswerRe: Re initializing an array in C++ ? Pin
Vaclav_27-Dec-18 9:09
memberVaclav_27-Dec-18 9:09 
GeneralRe: Re initializing an array in C++ ? Pin
Richard MacCutchan27-Dec-18 22:16
protectorRichard MacCutchan27-Dec-18 22:16 
QuestionC programming Question on Characters Pin
Member 1409794322-Dec-18 7:12
memberMember 1409794322-Dec-18 7:12 
AnswerRe: C programming Question on Characters Pin
David Crow22-Dec-18 16:46
memberDavid Crow22-Dec-18 16:46 
I see several things wrong with your approach: 1) The first time through the loop, tuna is uninitialized so the printf() statement is going to print an incorrect character, 2) The scanf() statement is expecting to receive a char (%c) but you are giving it the address of an int, 3) The isupper(), isalpha(), and isdigit() functions return a non-zero value if the parameter is an uppercase alphabetic letter, and zero otherwise. You are then comparing this to tuna. While syntactically correct, it is nonsensical, 4) If your password is to hold numbers, letters, and symbols, the password type should not be an int, but should probably be a string.

Consider something like:

int reqd = 0;
char pwd[32];
printf("Enter a password: ");
scanf("%s", pwd);
for (int x = 0; x < strlen(pwd); x++)
{
    if (isupper(pwd[x])) // this does not check for special characters
        reqd |= 0x1;
    else if (isalpha(pwd[x]))
        reqd |= 0x2;
    else if (isdigit(pwd[x]))
        reqd |= 0x4;
}

if (reqd == 0x07)
    printf("Requirements have been met.\n");
else
    printf("Requirements have NOT been met.\n");

"One man's wage rise is another man's price increase." - Harold Wilson

"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles


GeneralRe: C programming Question on Characters Pin
Member 1409794322-Dec-18 20:32
memberMember 1409794322-Dec-18 20:32 
GeneralRe: C programming Question on Characters Pin
jschell23-Dec-18 7:44
memberjschell23-Dec-18 7:44 
GeneralRe: C programming Question on Characters Pin
David Crow23-Dec-18 12:50
memberDavid Crow23-Dec-18 12:50 
GeneralRe: C programming Question on Characters Pin
David Crow23-Dec-18 12:54
memberDavid Crow23-Dec-18 12:54 
AnswerRe: C programming Question on Characters Pin
jschell23-Dec-18 7:43
memberjschell23-Dec-18 7:43 
AnswerRe: Spurious end of file error from ifstream::read Pin
Richard MacCutchan22-Dec-18 4:37
protectorRichard MacCutchan22-Dec-18 4:37 
QuestionPostMessage fails with ERROR_NOT_ENOUGH_QUOTA (PROBLEM FOUND, thanks all) Pin
Maximilien19-Dec-18 4:53
memberMaximilien19-Dec-18 4:53 
QuestionRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
David Crow19-Dec-18 5:13
memberDavid Crow19-Dec-18 5:13 
AnswerRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien19-Dec-18 6:45
memberMaximilien19-Dec-18 6:45 
AnswerRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Richard MacCutchan19-Dec-18 5:15
protectorRichard MacCutchan19-Dec-18 5:15 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien19-Dec-18 6:46
memberMaximilien19-Dec-18 6:46 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Richard MacCutchan19-Dec-18 21:56
protectorRichard MacCutchan19-Dec-18 21:56 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien20-Dec-18 2:04
memberMaximilien20-Dec-18 2:04 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Maximilien20-Dec-18 5:16
memberMaximilien20-Dec-18 5:16 
GeneralRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Richard MacCutchan20-Dec-18 6:06
protectorRichard MacCutchan20-Dec-18 6:06 
AnswerRe: PostMessage fails with ERROR_NOT_ENOUGH_QUOTA Pin
Randor 19-Dec-18 14:32
professional Randor 19-Dec-18 14:32 
QuestionMacro analysis - help wanted Pin
Vaclav_18-Dec-18 3:43
memberVaclav_18-Dec-18 3:43 

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.