Jump to content

Recommended Posts

Posted

Guys i made a password program in C which will just store the passowrd entered by user And will ask user to type show to show password entered ...In this i included other things too show program real kinda comments are with program but it give 6 errors while compiling please help guys.!!

#include <stdio.h>

#include<conio.h>

#include<string.h>

#include<windows.h>

int main()

{

char intput[99999],pass,display;

int a,b,c,d;

printf("entert length of password"); /*password length for creating array */

scanf("%ch",input[pass]);

printf("please Enter the password you want in letters a-z And no. 0-9");

/* loop for storing each character in the array */

for(a=0;a<=input[pass];a++)

{

input[pass]=getch();

printf("*");

}

/*human testor say  not a bot test */

printf("\ntype 123 to proceed:"); /*User asked to type 123*/

scanf("%d",&B);

{

    if(b=123) /*If b is equal 123 than proceed or execute else part*/

    {

        printf("\nwait few seconds while we proceed");    /*Making user fool that we endeed processing*/

        for(c=0;c<=5;c++)

        {

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            Printf("\nCorrect Answer");

        }

    }

    else

    printf("\nTry again");

return 0; /*return to enter 123 again */

}

{

Printf("Type show for displaying password you have just entered"); /*User requested to Enter show to display password entered*/

scanf("%ch",&display);

if(display=show)

{

    printf("wait while we proceed"); /*Making it more realistic */

    for(d=0;d<=5;d++)

        {

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            printf(".");

            Sleep(100);

            Printf("\nCorrect Answer");

}

else

{

    printf("Try again");

return; /*return to enter show agin*/

}

}

printf("Your password:%ch",input[pass]); /*Dispay store info(password) in input[pass]*/

getch();

}

I made it myself so there is many possibilities that logic i used is 100% wrong if i'm 100% wrong please tell me thelogic to start with than i'll make another program.!!

Posted

Guys i made a password program in C which will just store the passowrd entered by user And will ask user to type show to show password entered ...In this i included other things too show program real kinda comments are with program but it give 6 errors while compiling please help guys.!!

I made it myself so there is many possibilities that logic i used is 100% wrong if i'm 100% wrong please tell me thelogic to start with than i'll make another program.!!

There are lots of errors in your program.

First of all you have declared your array as intput but throughout the program you have used input.

char intput[99999],pass,display;

Secondly your logic is wrong here. You have not used any variable to store the length of the password. I dont know what you have tried to do in your code here--

scanf("%ch",input[pass]);

Thirdly your scanning of the user input is totally wrong.

for(a=0;a<=input[pass];a++)
{
input[pass]=getch();
printf("*");
}
The correct code should be input[a]=getch() and in the loop you should replace input[pass] with a variable like len in which you store the length.

Fourthly this loop is wrong--

for(c=0;c<=5;c++)
        {
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            Printf("\nCorrect Answer");
        }

Your code will print Correct Answer 5 times. So keep only 1 printf and sleep in the loop and delete the rest and bring Correct Answer out of the loop.

Fifth who will this statement return to? --

printf("\nTry again");
return 0; /*return to enter 123 again */

You have not used any function. So who will the program return to? Your program will end here if you use this statement.

Sixth you have asked the user to type "Show" which is a character array but you are trying to store that in a single character here --

Printf("Type show for displaying password you have just entered"); /*User requested to Enter show to display password entered*/
scanf("%ch",&display);

Seventh, instead of comparing you have tried to assign a value in the if statement--

if(display=show)
{

Use the strcmp function here.

Eighth, you dont even know how to print a character array. Look at your code here--

printf("Your password:%ch",input[pass]); /*Dispay store info(password) in input[pass]*/
getch();

How can you print an entire password without using loops when you have stored the password in a character array? If you dont want to use loops just use strings instead of character arrays.

Posted

There are lots of errors in your program.

First of all you have declared your array as intput but throughout the program you have used input.

char intput[99999],pass,display;

Secondly your logic is wrong here. You have not used any variable to store the length of the password. I dont know what you have tried to do in your code here--

scanf("%ch",input[pass]);

Thirdly your scanning of the user input is totally wrong.

for(a=0;a<=input[pass];a++)
{
input[pass]=getch();
printf("*");
}
The correct code should be input[a]=getch() and in the loop you should replace input[pass] with a variable like len in which you store the length.

Fourthly this loop is wrong--

for(c=0;c<=5;c++)
        {
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            printf(".");
            Sleep(100);
            Printf("\nCorrect Answer");
        }

Your code will print Correct Answer 5 times. So keep only 1 printf and sleep in the loop and delete the rest and bring Correct Answer out of the loop.

Fifth who will this statement return to? --

printf("\nTry again");
return 0; /*return to enter 123 again */

You have not used any function. So who will the program return to? Your program will end here if you use this statement.

Sixth you have asked the user to type "Show" which is a character array but you are trying to store that in a single character here --

Printf("Type show for displaying password you have just entered"); /*User requested to Enter show to display password entered*/
scanf("%ch",&display);

Seventh, instead of comparing you have tried to assign a value in the if statement--

if(display=show)
{

Use the strcmp function here.

Eighth, you dont even know how to print a character array. Look at your code here--

printf("Your password:%ch",input[pass]); /*Dispay store info(password) in input[pass]*/
getch();

How can you print an entire password without using loops when you have stored the password in a character array? If you dont want to use loops just use strings instead of character arrays.

only that if(display=show) is corrected by me before u And sleep part too.!!

thanks for what u told as i said it seems easier for u And lil bit dificult for me to try all i tried myself okay i'll work again will try to fix it.!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...