#include // #include #include // My code #include "math_functions.h" #include "hello.h" #include "struct_test.h" #include "pointer_test.h" #include "read_file.h" // Test // https://stackoverflow.com/questions/8666378/detect-windows-or-linux-in-c-c #ifdef _WIN32 #include #endif #include "stdbool.h" // To setup this project on windows // 1. Install CMake // 2. Install Ninja with winget in windows 11: "winget install --id=Ninja-build.Ninja -e" // 3. Make a build directory in this project and cd into it // 4. Run this CMake command: "cmake -GNinja .." // 5. Change into Debug/Release folder // 6. Run this command to build: "cmake --build .. --config Debug" // https://phoenixnap.com/kb/install-gcc-windows // https://stackoverflow.com/questions/36770716/mingw64-make-build-error-bash-make-command-not-found // To build without installing Visual Studio: // 1. Download MingW64 from here: https://winlibs.com/#download-release // 2. Place the folder into C:\ // 3. Add this folder to the path: "C:\mingw64\bin" // 4. Download Make without guile from here: https://sourceforge.net/projects/ezwinports/files/ // 5. Copy files from make into "C:\mingw64", do not replace existing files! // 6. Create a build folder and cd into it // 7. Run this CMake command to generate build files: "cmake -G "MinGW Makefiles" .." // 8. To build Run "make" // TODO Look into getting current directory in Windows and Linux // https://stackoverflow.com/questions/27585930/get-the-current-working-directory-in-c-on-windows // TODO Move this into a different project. #ifdef _WIN32 void guiTest(){ } #endif // #define _FLIP_BOOLS // Hmm, very evil #ifdef _FLIP_BOOLS // This is just madness, inverting the boolean values :P #define true FALSE #define false TRUE // #define true (rand() % 2) // #define false (rand() % 2) #endif //_FLIP_BOOLS // TODO Look into making a gtk C program // https://www.geeksforgeeks.org/how-to-create-gui-in-c-programming-using-gtk-toolkit/ // Print out the memory addresses for each item in an array. void array_test() { // https://www.tutorialspoint.com/cprogramming/c_memory_address.htm // Int array int numbers[5] = {1,2,3,4,5}; int i = 0; printf("numbers = %p\n", numbers); do { printf("numbers[%u] = %p\n", i, (void *)&numbers[i]); i++; } while (i < 5); printf("sizeof(numbers) = %lu\n", sizeof(numbers)); } // https://www.tutorialspoint.com/cprogramming/c_ternary_operator.htm void check_even_odd(int num) { (num %2 == 0) ? printf("%d is even\n", num) : printf("%d is odd\n", num); } int main() { char welcomeMsg[] = "Welcome to KCNet"; // printf(welcomeMsg); uint16_t test = -2; // array_test(); // for (int i=0; i<5; i++) { // check_even_odd(i); // } // check_even_odd(1); // print_struct(); read_file("test.txt"); // This doesn't work // uint16_test(); //? 65534? Where is that number coming from // https://stackoverflow.com/questions/29112878/how-do-i-printf-a-uint16-t // printf("Number: %u", (unsigned int)test); // https://stackoverflow.com/questions/12120426/how-do-i-print-uint32-t-and-uint16-t-variables-value // printf("Number: %" PRIu32, test); // mathFunctions(); // print_struct(); int i = 22222; int* i_ptr = &i; // pointer_madness(i_ptr); #ifdef _FLIP_BOOLS bool testb = false; if (testb) { printf("True"); } else { printf("False"); } #endif //_FLIP_BOOLS // printf_example(); return 0; }