C/C++ declared with attribute warn_unused_result

I want to read a text file with C. This is my simple ilustration code :

When I compile this code I get warning message :

ignoring return value of ‘fgets’, declared with attribute warn_unused_result

This is because functions fgets returning char. To solve this problem, I change my code with :

Source :
http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/FUNCTIONS/fgets.html
http://www.codecogs.com/reference/computing/c/stdio.h/fgets.php