This question already has an answer here:

Add New user and password with sudo permission in Linux using programmatically in C or C++ language.

Exist solution like How can I add a new user as sudoer using the command line? ,In this case you need terminal but in my case it daemon process and i want do with programmatically in c or C++ language.

Note:- Deamon application so there is no user interface to set password manually.

marked as duplicate by muru, Zanna, Eliah Kagan, Eric Carvalho, Panther Nov 2 '17 at 14:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.