Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
|
||
|
||
int checkPassword(char *buffer){ | ||
|
||
int match; | ||
|
||
if (strcmp(buffer, "Selector") == 0){ | ||
return 1; | ||
} | ||
|
||
if (strcmp(buffer, "Specials") == 0){ | ||
return 2; | ||
} | ||
|
||
if (strcmp(buffer, "Beat") == 0){ | ||
return 3; | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
int returnVal = checkPassword(buffer); | ||
|
||
if (returnVal == 2){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
|
||
|
||
int checkPassword(char *buffer){ | ||
char passText[] = "ALongerString"; | ||
|
||
passText[7] = '\0'; | ||
int out = strcmp(passText, buffer); | ||
return out; | ||
} | ||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
//Get the Length | ||
int returnVal = checkPassword(buffer); | ||
|
||
if (returnVal == 0){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
|
||
int checkPassword(char *buffer){ | ||
|
||
char *magicWord = "HelloWorld"; | ||
|
||
if (strlen(buffer) > 5){ | ||
return -1; | ||
} | ||
|
||
for (int x=0; x<5; x++){ | ||
if (buffer[x] != magicWord[x]){ | ||
return -2; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
int returnVal = checkPassword(buffer); | ||
//int returnVal = process_first(buffer); | ||
|
||
if (returnVal == 0){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
|
||
|
||
int process_first(char *buffer){ | ||
|
||
int strlen = 0; | ||
|
||
//Work out length of string | ||
for (strlen = 0; strlen <= BUFFSIZE; strlen++){ | ||
if (buffer[strlen] == '\0'){ | ||
return strlen; | ||
} | ||
} | ||
return strlen; | ||
} | ||
|
||
int checkPassword(char *buffer, int strlen){ | ||
|
||
char magicWord[] = "HelloWorld"; | ||
|
||
char tempbuffer[strlen]; | ||
|
||
int y = 0; | ||
|
||
for (int x = strlen - 1; x >= 0; x--){ | ||
tempbuffer[y] = magicWord[x]; | ||
y+=1; | ||
} | ||
|
||
tempbuffer[strlen] = '\0'; | ||
|
||
if (strcmp(tempbuffer, buffer) == 0){ | ||
return 0; | ||
} | ||
else{ | ||
return -1; | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
//Get the Length | ||
int strlen = process_first(buffer); | ||
int returnVal = checkPassword(buffer, strlen); | ||
//int returnVal = process_first(buffer); | ||
|
||
if (returnVal == 0){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
|
||
|
||
int process_first(char *buffer){ | ||
|
||
int strlen = 0; | ||
|
||
//Work out length of string | ||
for (strlen = 0; strlen <= BUFFSIZE; strlen++){ | ||
if (buffer[strlen] == '\0'){ | ||
return strlen; | ||
} | ||
} | ||
return strlen; | ||
} | ||
|
||
int checkPassword(char *buffer, int strlen){ | ||
|
||
char magicWord[] = "HelloWorld"; | ||
|
||
char tempbuffer[strlen]; | ||
|
||
int y = 0; | ||
|
||
for (int x = strlen - 1; x >= 0; x--){ | ||
tempbuffer[y] = magicWord[x]; | ||
y+=1; | ||
} | ||
|
||
tempbuffer[strlen] = '\0'; | ||
|
||
if (strcmp(tempbuffer, buffer) == 0){ | ||
return 0; | ||
} | ||
else{ | ||
return -1; | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
//Get the Length | ||
int strlen = process_first(buffer); | ||
int returnVal = checkPassword(buffer, strlen); | ||
//int returnVal = process_first(buffer); | ||
|
||
if (returnVal == 0){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#define BUFFSIZE 30 | ||
#define PASSWORD "SwordF1sh!" | ||
|
||
void main(void){ | ||
char buffer[BUFFSIZE]; | ||
|
||
printf("Enter Password> "); | ||
fgets(buffer, BUFFSIZE, stdin); | ||
//Remove the Newlines | ||
buffer[strcspn(buffer, "\r\n")] = 0; | ||
|
||
if (strcmp(buffer, PASSWORD) == 0){ | ||
printf("Win!!\n"); | ||
} | ||
else | ||
printf("Lose\n"); | ||
|
||
} |