Java – Convert to any base (Binary, Octal, Hex)

Converting between decimal and an arbitrary base x is done by evenly dividing the decimal number to the base x until the division quotient is zero.   Example: converting 23 (decimal) to binary (base 2): 23 / 2 = 11, remainder 1 11 / 2 = 5, remainder 1 5 / 2 = 2, remainder 1 2 / 2 … Read more

Write to file struct containing char pointer

Writing to file a struct containing a dynamically allocated char* pointer Let’s say we have this struct Initializing it as a normal struct (not pointer to a struct) and printing the values It produces the following output struct test 20 But since it contains char* name and not something like char name[100] we can’t simply … Read more