It's more of a hint/possible solution towards what you need. As mentioned in the post it's something I quickly wrote down to show the idea of using a string you manipulate. It should work for an arbitrary bit count though, although I'm sure performance-wise it could be improved on.
You may use it, sure, but if you don't understand what's going on I don't see much of a point. I'll let you decide what you think is best for yourself.
-edit-
gonbe i tried to modify ur code for my problem but could't achieve, what i wanted
You should only have to change the define from 6 to 48. If that doesn't result in what you want I don't think I understand your problem correctly. If you set 48 it will take forever to finish, but that is to be expected with 2^48 strings that have to be calculated and printed. The logic of it should work. I'm not sure if I have time tomorrow to try to fix your existing code, it will probably be monday at the earliest if at any time. Try to figure out in the meanwhile what's going wrong and post your attempt(s). The bits increase, but that doesn't matter too much for the application's logic.