Since you seem to be insulted by my response, let me explain something. There is a huge difference between simply being a user and being a programmer. If you want to use a program, you can get around many or even most Windows programs without ever having to read any manual or readme or doing any work outside of fiddling with the program and seeing what happens. It's even the method I like to use, since many GUI applications function in similar ways.
If you try that approach with programming, your efforts will only frustrate those you ask for help as well as yourself. By all means, test things out, but don't write random things and expect them to work. What's even worse is that even if random things appear to work, very often that might be just what happens on the surface and what really is happening is not what you expected nor desired. Especially don't ask people why random things don't work. When you write code, you are telling the computer to do very specific things. Specific directions require logic that randomness will most likely not generate for you.
Sure, you open the file, forget to save the resulting FILE * that is returned, and then do nothing.
There is no reason to think fopen() reads a file line by line, and to be completely honest, it sounds like you pulled it out of nowhere as an excuse to get us to tell you exactly how to do the reading. Is that the case? I have no idea, and frankly, I don't care. Maybe you used to know how to read from a file and forgot. It's your program, and it's your project anyway. It doesn't bother me.
My irritation is that it appears you have not done any real research into how file processing or even fopen() works and just slapped it together and wanted us to do it. If you're interested in becoming an expert, you need to be able to better understand what your problem is before you ask others for help. This means you should have read a basic file tutorial first, and also had basic knowledge on how to use fopen(), fclose(), and hopefully some file input functions. It's considered common courtesy to the rest of us who you've asked to help you out, to at least know what you're talking about and to make an honest effort.
So back to what I said in my past post:
- Your function names are bad. Naming something generic like function() is a way to totally confuse yourself and others viewing your code. Things like that are usually meant to obfuscate code. If you pick meaningful names like playSong() or readSongList(), then it would be easier to figure out what is going on.
- Your usage of fopen() is wrong. You need to declare a FILE * and set it equal to the result of fopen() and then test it to see if that is NULL. If it isn't, then your file is successfully opened. Go ahead and read from it. After that, remember to call fclose() on the FILE *.
- I don't know where you got that fopen() does reading, but it's horribly wrong. If someone told you this or you read it from a website, consider ignoring most of what they say regarding C. If you made it up, then see what I wrote above regarding random code.