diff --git a/Topic5_Editing/flowThree.c b/Topic5_Editing/flowThree.c new file mode 100644 index 0000000..cc26725 --- /dev/null +++ b/Topic5_Editing/flowThree.c @@ -0,0 +1,58 @@ +#include +#include +#include + +#define BUFFSIZE 30 + +int getPassword(char* buffer){ + /* Get the Password */ + printf("Enter Password> "); + fgets(buffer, BUFFSIZE, stdin); + //Remove the Newlines + buffer[strcspn(buffer, "\r\n")] = 0; + printf("\nYou put %s\n", buffer); +} + +void showSuperWin(char* command){ + printf("Super Win\n"); + system(command); +} + +void showWin(void){ + printf("Congratulations you win\n"); +} + +void showLose(void){ + printf("Lose\n"); +} + +void main(void){ + char buffer[BUFFSIZE]; + char *expected = "Swordfish"; + + getPassword(buffer); + + if (strcmp(buffer, expected) == 0){ + __asm__("nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop\n\t" + "nop"); + showWin(); + } + else{ + showLose(); + } +}