I found out a terminal command to rename a window in x11. But I am looking for a xlib function (a C code snippet) for naming a newly created window. I looked into the window attributes, but there is no option for that.
For creating new window: https://rosettacode.org/wiki/Window_creation/X11#C
For window attributes: https://tronche.com/gui/x/xlib/window/attributes/
For command-line renaming: https://unix.stackexchange.com/questions/286723/how-does-one-change-the-title-of-any-window-in-x