Hey everyone,

I'm a program newbie, I'm writing a code for sorting numbers from a input file,


qsort(array, array_size, sizeof(int), (*compare)(const void *, const void *));

since the array_size may vary for different file, I can't just use
int array_size= some #

How would I write this? Thank you very much!

Recommended Answers

All 2 Replies

You should know how many items you have read and put it as parameter array_size.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.