C programming language

Talk about anything.
17 posts Page 2 of 2

Naruk

User avatar
Naruk
Posts: 1042
Joined: July 8, 2013, 1:51 pm
Location: Visayas, Cebu, Cebu City

Post by Naruk » June 11, 2016, 3:37 pm
First check the number of characters in a password
Dim pass as string

Input = pass

If pass <= 20characters idk le exact language
Else display(20chars plz)
Then
For i,j, k = pass' characters idk le exact lang
If pass ≠ uppercase
If i = maximum limit Then display(wrong), end
Then next i
Elseif pass[j] ≠ lowercase
If i = maximum limit then display(wrong),end
Then next j
Elseif pass[k] ≠ digit
If k = maximum limit then display(wrong), end
Then next k
Elseif Display(You got the way of how the pass should be done)

Idk 6 months ago when I learned VB6 but forgotten most of dem words already, btw its judt a concept, idk how u translate it
"LIfe is fair because it is unfair to everyone."

An ordinary player.

IDoNotKeyBind

IDoNotKeyBind
Posts: 84
Joined: March 24, 2016, 9:37 am

Post by IDoNotKeyBind » June 11, 2016, 3:46 pm
Jaker wrote:
Here, this is what my bro has written(source: https://gist.github.com/anonymous/25693 ... 4a781c260e)
Code: Select all
#include <stdio.h>
#include <ctype.h>

char s[100];

int main() {
  scanf("%s", s);

  int has_upper = 0;
  int has_lower = 0;
  int has_digit = 0;
  int has_dollar = 0;

  for (char *c = s; *c; ++c) {
    if (isupper(*c)) has_upper = 1;
    if (islower(*c)) has_lower = 1;
    if (isdigit(*c)) has_digit = 1;
    if (*c == '$') has_dollar = 1;
  }

  if (strlen(s) <= 20 && has_upper && has_lower && has_digit && has_dollar)
    puts("Strong");
  else
    puts("Weak");

  return 0;
}
Thank you and to your brother! I would like to thank everyone who posted here and used their brains, domeone might lock this now.

[Lsrcr]Oggy

User avatar
Oggy
Posts: 2507
Joined: August 26, 2014, 6:29 am
Location: Los Santos

Post by [Lsrcr]Oggy » June 11, 2016, 4:02 pm
Shirt wrote:
ATGOggy wrote:
Go through all the characters of the password and for a character ch,

1) if (ch >= 'A' && ch <= 'Z') then it's a upper case letter
2) if (ch < 'A' || ch > 'Z') then it's a lower case letter
3) if(isdigit(ch)), then it's a digit
4) if(strlen(password)>=20), this checks if the password has atleast 20 characters
5) if(ch=='$')


EDIT: For going through each characters,

char ch;
for(i=0; i<strlen(password); i++)
{
ch=password;
blah blah blah
}

thank you so much for your guidelines, would definitely try out this.
but what I didn't get here is, this part
char ch; \\got it
for(i=0; i<strlen(password); i++) \\the part which I didn't get
{
ch=password
please explain me that 'for' part.

@Auto;
No, it is not any homework, I was just learning C programming through youtube because it cost too much to learn from any IRL teacher. And I saw this question in some forums I suppose and then was not able to do it. So, I thought let's ask you guys.
@Jaker;
Would appreciate your help, mate.

You know how 'for' loops work, right?

I don't know how to explain it xD So I'll give you an example.
Suppose there's a string -

char string[]={'H', 'e', 'l', 'l', 'o', '\0' }

so value of string[0] will be 'H'
string[1] = 'e'
string[2] = 'l'
string[3] = 'l'
strong[4] = 'o'
Image

IDoNotKeyBind

IDoNotKeyBind
Posts: 84
Joined: March 24, 2016, 9:37 am

Post by IDoNotKeyBind » June 11, 2016, 4:10 pm
ATGOggy wrote:
Shirt wrote:
ATGOggy wrote:
Go through all the characters of the password and for a character ch,

1) if (ch >= 'A' && ch <= 'Z') then it's a upper case letter
2) if (ch < 'A' || ch > 'Z') then it's a lower case letter
3) if(isdigit(ch)), then it's a digit
4) if(strlen(password)>=20), this checks if the password has atleast 20 characters
5) if(ch=='$')


EDIT: For going through each characters,

char ch;
for(i=0; i<strlen(password); i++)
{
ch=password;
blah blah blah
}

thank you so much for your guidelines, would definitely try out this.
but what I didn't get here is, this part
char ch; \\got it
for(i=0; i<strlen(password); i++) \\the part which I didn't get
{
ch=password
please explain me that 'for' part.

@Auto;
No, it is not any homework, I was just learning C programming through youtube because it cost too much to learn from any IRL teacher. And I saw this question in some forums I suppose and then was not able to do it. So, I thought let's ask you guys.
@Jaker;
Would appreciate your help, mate.

You know how 'for' loops work, right?

I don't know how to explain it xD So I'll give you an example.
Suppose there's a string -

char string[]={'H', 'e', 'l', 'l', 'o', '\0' }

so value of string[0] will be 'H'
string[1] = 'e'
string[2] = 'l'
string[3] = 'l'
strong[4] = 'o'

Thank you for further explanation.
[UC]Agent_Oggy. Right??

[Lsrcr]Oggy

User avatar
Oggy
Posts: 2507
Joined: August 26, 2014, 6:29 am
Location: Los Santos

Post by [Lsrcr]Oggy » June 11, 2016, 4:45 pm
IDoNotKeyBind wrote:
[UC]Agent_Oggy. Right??
No, I'm AtgOggy or [Lsrcr]Oggy or Oggy :D
Image

IDoNotKeyBind

IDoNotKeyBind
Posts: 84
Joined: March 24, 2016, 9:37 am

Post by IDoNotKeyBind » June 11, 2016, 4:47 pm
ATGOggy wrote:
IDoNotKeyBind wrote:
[UC]Agent_Oggy. Right??
No, I'm AtgOggy or [Lsrcr]Oggy or Oggy :D
Ah i though you were that guy, he used to play back in 2013, he was cute tho :O

[Lsrcr]Oggy

User avatar
Oggy
Posts: 2507
Joined: August 26, 2014, 6:29 am
Location: Los Santos

Post by [Lsrcr]Oggy » June 11, 2016, 4:48 pm
IDoNotKeyBind wrote:
ATGOggy wrote:
IDoNotKeyBind wrote:
[UC]Agent_Oggy. Right??
No, I'm AtgOggy or [Lsrcr]Oggy or Oggy :D
Ah i though you were that guy, he used to play back in 2013, he was cute tho :O
I'm cute too -_-
Image
17 posts Page 2 of 2
Return to “The Bar”

Who is online

Users browsing this forum: No registered users and 1 guest