how to clear a file in linux

C++
: > file.log
> filename
# Just cd To the Correct Path, and Type the Following:
> filename
Source

Also in C++: