The function getlogin_r()
defined in unistd.h
returns the username. See man getlogin_r
for more information.
Its signature is:
int getlogin_r(char *buf, size_t bufsize);
Needless to say, this function can just as easily be called in C or C++.
More Related Contents:
- Linux: Executing child process with piped stdin/stdout
- Why does the library linker flag sometimes have to go at the end using GCC?
- C++ error: undefined reference to ‘clock_gettime’ and ‘clock_settime’
- Is there an equivalent to WinAPI’s MAX_PATH under linux/unix?
- What’s the difference between 'gcc -g' and 'gcc -g3'?
- How to judge an address as legal or illegal by it‘s numerical value? [closed]
- How to allocate memory dynamically for class using new in C++?
- usr/bin/ld: cannot find -l
- Compiling multithread code with g++
- How do you find what version of libstdc++ library is installed on your linux machine?
- C++ compiling on Windows and Linux: ifdef switch [duplicate]
- Difference between shared objects (.so), static libraries (.a), and DLL’s (.so)?
- How can I execute external commands in C++/Linux?
- How can I set the baud rate to 307,200 on Linux?
- How to update a printed message in terminal without reprinting
- Complete C++ i18n gettext() “hello world” example
- fork() and output
- How do I clear the console in BOTH Windows and Linux using C++
- Possible causes for Boost not being found by CMake in certain situations?
- Linux/POSIX equivalent for Win32’s CreateEvent, SetEvent, WaitForSingleObject
- Where are the man pages for C++? [closed]
- C++ Boost ASIO simple periodic timer?
- Efficiently reading a very large text file in C++
- Why infinite recursion leads to seg fault
- Forcing or preventing use of a particular minor version of libstdc++
- Linux c++ error: undefined reference to ‘dlopen’
- Linux shared memory: shmget() vs mmap()?
- “to_string” isn’t a member of “std”?
- How to force inclusion of an object file in a static library when linking into executable?
- Exception running boost asio ssl example