Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #define DIM 3  
  2. #define DIM_A 3
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. int main(){
  6.       char *strings[] = {"uno","due","tre"};
  7.       char buf[] = "tre:due:uno";
  8.       int i;
  9.       char *p;
  10.       char *array[DIM];
  11.       i = 0;
  12.       p = strtok (buf,":");  
  13.       while (p != NULL)
  14.       {
  15.         array[i++] = p;
  16.         p = strtok (NULL, "/");
  17.       }
  18.       for (i=0;i<DIM; ++i)
  19.         printf("%s\n", array[i]);
  20.      
  21.      
  22.     int j = 0;
  23.     char cacca[strlen(buf)];
  24.  
  25.     for (i = 0; i< DIM_A ; i++){
  26.             for (j = 0; j< DIM ; j++){
  27.                     if (strings[i] == array[j])
  28.             if(i == DIM_A -1)
  29.                 strcat(cacca, array[i]);
  30.             else{
  31.                 strcat(cacca, strcat (array[i],":"));
  32.    
  33.             }
  34.         }
  35.     }
  36.  
  37.     return cacca;
  38.    
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement