08-12-2008 09:25 AM
08-14-2008 09:37 AM
Francois,
You can accomplish this with a for loop, sprintf, strcat, and some basic if-then logic.
Loop through each element in the array. As you do, maintain a separate variable that is the next expected value (initialized to the first value in the array). If the current array value doesn't match the expected value, then it's time to create a sub-string and add it to your main string. The format of the string will depend on whether you've had more than one number in a row or not. Once the sub-string is created, concatenate it to your main string.
Tony
08-14-2008 02:29 PM
08-14-2008 02:34 PM
Good point about the sorting. If it's not already sorted, you can sort it easily with qsort.
Tony