diff --git a/main.c b/main.c index 2f8e76c..383cc34 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,25 @@ //importing basic modules #include -#include +#include +#ifdef _WIN32 + #include + #define GETCH() _getch() +#else + #include + #include + char getch() { // Fucking painful why is this piece of shit needed on UNIX Based/Unix-like systems 🫩 + struct termios oldt, newt; + tcgetattr(STDIN_FILENO, &oldt); // save old settings + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); // disable buffering and echo + tcsetattr(STDIN_FILENO, TCSANOW, &newt); // apply new settings + char ch67 = getchar(); // read one char instantly + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // restore old settings + return ch67; + } + #define GETCH() getch() +#endif // STRUCTURE TEST struct man { @@ -123,6 +141,15 @@ int main() { LOIS.weight = 60; printf("Our woman is unknown, she is not %d years old and she weights %dkg. (LOIS.age and LOIS.weight).", LOIS.age, LOIS.weight); + // PRESS ANY KEY TO CONTINUE + printf("\n\nPress any key to continue..."); + GETCH(); + #ifdef _WIN32 + system("cls"); + #else + system("clear"); + #endif + // INPUT (BUT ONLY FOR ONE WORD! STOPS WHEN YOU PUT IN A SPACE) printf("\n\nINPUT BELOW:\n"); // DIVIDER char fruit[50]; //MAX 50 CHARACTERS @@ -140,7 +167,19 @@ int main() { scanf(" %49[^\n]", vegetable); // the "[^\n]" means to read everything except a newline, which means you can input spaces inside now, 49 makes it so it doesnt crash once it has more than 50 characters printf("The %s will be a perfect choice for this salat!", vegetable); - // END - return 0; - // THIS IS THE CURRENT END OF MY LESSON + // END OF THE MAIN.C CODE, HERE YOU WILL BE ABLE TO CONTINUE ON TO OTHER EXPERIMENTS OF MINE + printf("\n\nSWITCH OVER TO\n"); // DIVIDER + printf("1 = DvorakMSDOS.C, 2 = exit\n"); + while (getchar() != '\n') {} // same use case as above in the first input part of the code + while (1==1) { + fflush(stdout); // same use case as above in the first input part of the code + char chc = GETCH(); + if (chc == '1') { + printf("placeholder"); + } else if (chc == '2') { + return 0; + } else { + printf("invalid character, try again!\n"); + } + } } \ No newline at end of file