Challenge #1 problem

+1 Ahmed Samir · August 6, 2015
Hey guys i tried to solve challange no.1 today and that's the code i made 


int main(){

char a = 'a';
char password[10]  ;
int lower, upper, sympol, num ,i;
lower = upper = sympol = num = 0;

scanf_s("%s", password);

for (i = 0; i = 1 && lower >= 1 && sympol >= 1 && num >= 1){
printf("well done");
printf("you suck");


scanf_s("%c", &a);

return 0;

but then everytime i try to to run the code and enter any value i get this 


i checked the code many times ... but i can't even understand what is the error about

Thanks in advance 

Post a Reply


- page 1
Oldest  Newest  Rating
0 Tracia william · August 14, 2015
Hi everyone,I will like to utilize these stage to give a major 

praise to the bucky  and all the followers of this forum.
A guy i met on this forum has really transformed my life
by introducing me to a powerful tool that has enble me to get promotion at my work place and has boost my accadmic work.I used this tool to creat awesome advertising, presentation for our product and service.
 Thank you Liman, for introducing me to this wonderful tool.You guys can check it out .Thanks Thanks
0 Toyen . · August 12, 2015
Hey there Jap!

Congrats on completing the challenge, but I dont get the "i flag" thing you have there, what exactly is the intention?
0 JAPJEET SINGH · August 11, 2015
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main()

    char pass[20];
    int i,flag;
    printf("Enter the password:");
    scanf(" %s",pass);

            printf("good password");
            printf("bad password");
    return 0;
0 Toyen . · August 11, 2015
Oh I get it now!

I also forgot to account for the string terminator so I changed that as well to 4 bites and now the program works!

I completed the challenge! : D : )
0 c student · August 10, 2015
arrays start from 0, not 1 as you have done
0 Toyen . · August 10, 2015
Thank you!

My program now works however I am having another issue.

If I enter a correct password where the first character is an upper case letter, second is a digit and third is the dollar sign, it still says that the password is invalid.

What am i doing wrong?
0 c student · August 9, 2015
youre missing a closing parenthesis on your if statement.  also your ctype functions are supposed to be all lower case
0 Ahmed Samir · August 8, 2015
thanks man i modified the code and it worked 
the main cause of the problem was that i was telling my program to check for 30... but what if he entered only 21 or 9?

had to use this function -- strlen(variable)-- it checks for the length of the string... so the new for loop is 
----for (i = 0 ; strlen(password) ; i++) ---
0 Toyen . · August 8, 2015
Hey there!

I´m trying to do this challenge myself at the moment but I don´t understand your code.

What are all these ints and why are you setting them equal to 0?

And how are they connected to the password char the user will be inputting?

Anyways here is my approach.

If I got it right, I was to ask the user to choose a password where first character would be an upper case letter, second a number and third the dollar sign.


But mine does not work as well.

I´m getting the following errors:


I´d be glad for any help! : )
0 c student · August 8, 2015
why are you checking up to 30?  you're reading memory that's out of bounds of your array.
  • 1
  • 2



One of the most popular languages of all time.

Bucky Roberts Administrator