I'm a beginner in C and I need a function or implementation that returns a random line from a file .
Printable View
I'm a beginner in C and I need a function or implementation that returns a random line from a file .
Read the entire file into an array of strings, then shuffle the array:
SourceForge.net: Randomizing an array - cpwiki
Finally, use rand() to pick a line from the shuffled array.