applying same logic once for 2 fields - TechRepublic
General discussion
May 18, 2003 at 08:17 PM
jpsarkar_2001

applying same logic once for 2 fields

by jpsarkar_2001 . Updated 23 years ago

I am writing a simple ansi c program. I have a link list(say X) having two integer fields(say a and b) for each node. I have to sort them separately but the sorting logic is same. so i need a function which’ll be called from main. now in my sorting function if i want to sort field “a” then i have to refer it as X.a. also for “b” it is X.b
naturally i am writing samething twice(one for “a” and one for “b”) .
Can anyone say that how can I accept “a” or “b” as variable, so that for sorting “a” or “b” i have to write code only once.

This discussion is locked

All Comments