how to edit etc/hosts linux error readonly e45

C++
sudo vim /etc/hosts or sudo nano /etc/hosts$ chattr -i /etc/hosts
Source

Also in C++: