As an alternative to the existing answers: Use while
if your file names can contain blank spaces like this:
find . -name foo.txt | while IFS= read -r var; do
echo "$var"
done
As I wrote, the difference is only relevant if you have to expect blanks in the file names.
NB: the only built-in stuff is not about the output but about the status of the last command.