remove last field using awk

C++
awk 'NF{NF-=1};1' <in >out
Source

Also in C++: