paulogp

getlogin

Jul 20th, 2011
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. // title: login
  2. // ide: apple xcode
  3. // author: paulogp
  4.  
  5.  
  6. #include <stdio.h>
  7. #include <unistd.h>
  8.  
  9. int main (int argc, const char * argv[])
  10. {
  11.     // shall return a pointer to a string containing the user name associated
  12.     // by the login activity with the controlling terminal of the current process.
  13.     // if getlogin() returns a non-null pointer, then that pointer points to the
  14.     // name that the user logged in under, even if there are several login names
  15.     // with the same user ID.
  16.     printf("username: %s\n", getlogin());
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment