He would, if he were using C/C++/etc. However, according to his threads on this topic, his homework is to write a shell script. Luckily, there are simple programs that do call getpwnam() and have exit status to test.
There must be Fora out there focused on basic shell scripting and less focused on the use of C++ to interact with UNIX-like system.