C - Function that returns a random line from a file

I'm a beginner in C and I need a function or an idea of an implementation that returns a random line from a file .
There isn't one.

You can generate a random number (with rand()) and you can read lines from an opened file (with getline()), but you'll have to put it together yourself.

EDIT: getline is a C++ standard library function. Do you mean C or C++?
Last edited on
Topic archived. No new replies allowed.