How to write a program which can print the name of the user logged in on the controlling terminal of the process ?

https://raw.githubusercontent.com/ahiliation/beautifulwork-programmingpractice/master/user-p1.c