Challenge 1 (Needs improvement and fixing)

0 Seray Dönmez · February 11, 2015

Here is the code i wrote for the challenge 1 but there's some bugs i've seen. Please help me to fix them.
First of all, when i write a password that has more than 20 characters, the programs crashes. I tried some ways, but i couldn't fix it. Secondly when i write only numbers as a password, it checks the condition of having a capital letter and it prints "Capital test : 1 Passed". I don't understand why it does that. Please help me to fix the bugs and if you have any advices to improve the program, please tell me. Thank you. :)

Post a Reply


Oldest  Newest  Rating
0 Lazar Bulic · February 11, 2015
there is a big chunk of code missing. try posting your code here:

This forum doesn't show code correctly. 
0 Emir ARITURK · February 11, 2015
One of the biggest problem in your code is at the beggining, "the header parts" Turns out you've written just  #include for the libraries that you wanted to use but which libraries you want'em to be? Check it out a few times again, then it'll be much easier to make it feasible somehow :)
0 c student · February 11, 2015
i think there's a problem with displaying the included header files in the code box
0 Seray Dönmez · February 11, 2015
Wow, yea. I edit it, please look at the website i shared. :) 
0 c student · February 11, 2015
the reason your program crashes is because of a segmentation fault where you are writing/reading invalid memory.
when you have a buffer of 20 characters, you only have 20 spaces to hold your input from scanf().  once you have breached the 20 limit, you start to write into other variables, i.e. check, capital, number and sign as i have boxed in red in the first image.  because of this, your values will then remain the same throughout the rest of the program and when you come to test these values, they will pass your if statements.  on the second image, i have inputted a much longer string and as you can see "invalid read size of 4", it means that you are trying to access memory outside of your program stacks - 4 probably because it is size of int.
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator