how to save a text file with a terminal command

C++
echo "insert text here" > filename.txt
Source

Also in C++: