Skip to content
Permalink
Browse files
rename Folders to be more sensible
  • Loading branch information
aa9863 committed Sep 25, 2023
1 parent b4f0bdb commit 040c0c153eb6e16a5c42ccc8f7473584d5a70306
Show file tree
Hide file tree
Showing 14 changed files with 273 additions and 0 deletions.
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.
@@ -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");

}
@@ -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");

}
@@ -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");

}
@@ -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");

}
@@ -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");

}
@@ -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");

}

0 comments on commit 040c0c1

Please sign in to comment.