52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/*
|
|
* capp.c
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <signal.h>
|
|
|
|
#define BUFFER_SIZE 20
|
|
|
|
int main()
|
|
{
|
|
char correctPassword[BUFFER_SIZE];
|
|
char suppliedPassword[BUFFER_SIZE];
|
|
|
|
printf("\nEnter the password now: ");
|
|
strncpy(correctPassword, "aaaaabbbbbccccc", BUFFER_SIZE);
|
|
scanf("%19s", suppliedPassword);
|
|
printf("\n");
|
|
|
|
if (strncmp(suppliedPassword, correctPassword, BUFFER_SIZE) == 0)
|
|
{
|
|
printf("Login successful\n\n");
|
|
}
|
|
else
|
|
{
|
|
printf("Login failure\n\n");
|
|
}
|
|
|
|
printf("suppliedPassword: %s\n", suppliedPassword);
|
|
printf("sizeof(suppliedPassword) = %d\n", sizeof(suppliedPassword));
|
|
printf("strlen(suppliedPassword) = %d\n", strlen(suppliedPassword));
|
|
|
|
printf("correctPassword: %s\n", correctPassword);
|
|
printf("sizeof(correctPassword) = %d\n", sizeof(correctPassword));
|
|
printf("strlen(correctPassword) = %d\n", strlen(correctPassword));
|
|
|
|
char myArray[BUFFER_SIZE];
|
|
scanf("%s", myArray);
|
|
printf("myArray: %s\n", myArray);
|
|
printf("sizeof(myArray) = %d\n", sizeof(myArray));
|
|
printf("strlen(myArray) = %d\n", strlen(myArray));
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|