I would like to build a program which takes a username as parameter and creates the user and its home folder (with some hard-coded specifications like folde
Probably your best bet is to invoke useradd; it will do the right things (given appropriate parameters).
Trying to create one manually by calling the appropriate APIs is possible but not desirable.