c - grouping strings in a struct -


I have strings that look like:

'Hello1-FOO', ' Allo 2-Foo ',' Bye-1-Br ',' By 3-BR ',' Hello 22-Fu ',' Bye-4-Bar ',' Welcome-Bar '...

All are stored on one of these structures.

  struct str {char * wire; } ... struct str ** t_str; Size_t; J T_str = Molok (size * t_str * 20); For (j = 0; j; l; 20; j ++) t_str [j] = maulok (size of size * t_str [j]); ... t_str [0] - & gt; String = "hello 1-fu"; T_str [1] - & gt; String = "alo 2-fu"; ....  

What I have to do is display them (sorted) according to the category, so they look like this:

  FOO : Hello1-FOO Aello2-FOO Hello-22-FOO Bar: BY-4-Bar Welcome-By BY1-BY BY3-BAR  

Basically give them '-'

< P> What would be a good way to do this? Should I store the string on the second structure after processing it? Any idea will be appreciated Thanks

Use the following code to make some assumptions You should be able to change it to suit your needs.

  int file file (constant void * a, const void * b) {char * string1 = (char *) a; Four * string2 = (four *) b; String 1 = string (string 1, '-') + 1; String 2 = Struggle (String 2, '-') + 1; Return strcmp (string 1, string 2); } {... char * strings] []; // String Points array of int string; // puts the number of existing elements in the wires. ... qsort (strings, string coat, psychof (four *), category compressor); }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -