Okay, little bit of misinformation and guessing in the thread. What you're doing won't work, but not for the reasons people seem to think.
First, the documentation for system() will quickly clear up the notion that calling system() doesn't invoke the shell. In fact on a unixlike system that's exactly what it does. "The system() function hands the argument string to the command interpreter sh(1)."
sh on most modern systems, including Darwin, is just a link to or copy of bash. In Darwin /bin/sh is a copy of /bin/bash. You can tell because they have different permissions (hardlinks share permissions). The two files are otherwise identical.
The ordinary way to invoke the shell directly with a string of commands (from a shell prompt) would be to run, for instance, "bash -c history". The -c switch tells bash to accept its commands from the command line as a non-interactive shell. This is pretty much exactly what your call to system() is doing.
If you try running "bash -c history" at the command prompt right now, you'll see why you didn't get any results. "history" does nothing in the non-interactive context. This is also why mrichmon's code sample will, in fact, work. By forcing an interactive shell with the -i switch, the history will be available.
Depending on a number of factors you may still not be out of the woods. You may find your default shell is tcsh instead of bash. system() will still invoke bash (do NOT try to replace /bin/sh with /bin/tcsh), and the two have mutually incomprehensible history schemes. For that matter, you may find that your history is not properly heritable between sessions, so the results of your program will not necessarily be the last few things you typed on the command line in your current interactive session.
For this reason, if all you want is a command that shows you only the last few commands you typed, what you want is neither C nor shell scripts, but aliases. The only difference between bash and tcsh is that bash requires an '=' in the definition and tcsh requires none. To find out your current shell, type "echo ${SHELL}" at the command prompt.
bash: alias shorthistory='history | tail -10'
tcsh: alias shorthistory 'history | tail -10'
Thereafter, every time you type 'shorthistory' you'll get what you expect. Substitute whatever command you like for "shorthistory," of course. You can persist this change by inserting the appropriate line above into the appropriate file below:
bash: ~/.bash_login
tcsh: ~/.login
(where ~ indicates your home directory)
Commands in these files are loaded when you open a new login shell, and will keep their effects even after a reboot.