In addition to a check for fopen() returning NULL, you must also check that fscanf() returns 1 here.
If a float value isn't converted by fscanf(), then the myData variable is uninitialized, and attempts to print it can fail. The returned value from fscanf() tells you how many items were actually converted, or EOF if the input has been exhausted.
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/fscanf.3.html
RETURN VALUES
These functions return the number of input items assigned. This can be fewer than provided for, or
even zero, in the event of a matching failure. Zero indicates that, although there was input available,
no conversions were assigned; typically this is due to an invalid input character, such as an
alphabetic character for a `%d' conversion. The value EOF is returned if an input failure occurs
before any conversion such as an end-of-file occurs. If an error or end-of-file occurs after conversion
has begun, the number of conversions which were successfully completed is returned.
To find out what's actually in your input file, open a Terminal window, then copy and paste this line into it:
Code:
hexdump -C /Users/oliverburns/Documents/Document1.txt | head -n 5
Then copy and paste the complete output and post it here.
If an error message is produced, copy and paste that in its entirety.
It's possible that the file exists and is named "Document1.txt", but it's not actually a plain text file. This would almost certainly cause fscanf() to fail its conversion.
Finally, if you're following a tutorial or book, please tell us exactly which one. That is, the URL of an online tutorial, or the title, author and edition of a book.
If you're not following a tutorial, you probably should be, because the posted code shows a lot of mistakes that a decent step-by-step tutorial will cover.
If might also help to tell us exactly which engineering field you're a student in.