c - qsort an array of strings, compare -


I'm trying to find out the use of qsort with an array of strings, my code looks like this < / P> Four words [500] [256]; Int numOfWords; // It is calculated from the intert wordlist above () {int length = cecoff (word) / size (four *); Cursure (word, length, sizeoff (four *), compare); } Compare Int (Cont Woed * A, Constwid * B) {const char * pa = * (const char **) a; Const char * pb = * (const char **) b; Return SRCMP (PA, PB); }

However, I get "access violation # 0x # # ### .." every time and I do not know whether anyone can see my problem?

EDIT: Thanks for the wonderful help you guys are always best.

You are not casting your const void * properly, such a To do this, use instead:

  const char * pa = (const char *) a; Const char * pb = (const char *) b;   

plus should be above the comparison sortWordList () as you are using it in sortWordList () Code>.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -