Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Although what you are saying is correct and it is nice to point that a better data structure could be used, an array in this case is not really O(n*m), because m is a constant (does not change with input) and does not impact in the asymptotical analysis Big Oh provides.
It does not matter what parameters I give to that function, it always returns 0. For example, if I call the function like this numToBin(10u,5u). Am I doing something wrong? :P
Are you sure it works? It does since num & (1 << shift) ALWAYS returns 0. I do not really know why it returns 0 every time, does not matter the number or what shift's value is
Thank you for answering! I just cannot get my head around move semantics so I use it when I feel to. I know this is not good practice but I felt like that would improve my code :/ . Also, what looked interesting since it could potentially speed up my algorithm was avoiding using reverse, however, the code that you put there does not work :P
Thanks for answering! All of what you said worked flawlessly, again, thanks. After changing my code a little bit more, it now works with a capital letters and hyphens. Here's my code if you want to check it out I do believe there's some memory leaking somewhere, but I can't find where... Anyways, thanks!